Skip to content

Commit

Permalink
PR feedback - add null check on ctor
Browse files Browse the repository at this point in the history
  • Loading branch information
stevejgordon committed Nov 21, 2024
1 parent 0d433b4 commit fb0a516
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Elastic.Transport/Responses/Special/StreamResponseBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

using System;
using System.IO;
using Elastic.Transport.Extensions;

namespace Elastic.Transport;

/// <summary>
/// A base class for implementing responses that access the raw response stream.
/// </summary>
public abstract class StreamResponseBase(Stream stream) : TransportResponse, IDisposable
public abstract class StreamResponseBase : TransportResponse, IDisposable
{
/// <inheritdoc/>
protected internal override bool LeaveOpen => true;
Expand All @@ -21,13 +22,20 @@ public abstract class StreamResponseBase(Stream stream) : TransportResponse, IDi
/// <remarks>
/// <b>MUST</b> be disposed to release the underlying HTTP connection for reuse.
/// </remarks>
protected Stream Stream { get; } = stream;
protected Stream Stream { get; }

/// <summary>
/// Indicates that the response has been disposed and it is not longer safe to access the stream.
/// </summary>
protected bool Disposed { get; private set; }

/// <inheritdoc cref="StreamResponseBase"/>
public StreamResponseBase(Stream responseStream)
{
responseStream.ThrowIfNull(nameof(responseStream));
Stream = responseStream;
}

/// <summary>
/// Disposes the underlying stream.
/// </summary>
Expand Down

0 comments on commit fb0a516

Please sign in to comment.