Merge remote-tracking branch 'origin/master'

This commit is contained in:
Christian Kratky
2020-06-12 11:19:36 +02:00
2 changed files with 17 additions and 2 deletions
@@ -127,7 +127,14 @@ namespace MQTTnet.Implementations
// Workaround for: https://github.com/dotnet/corefx/issues/24430
using (cancellationToken.Register(Dispose))
{
return await _stream.ReadAsync(buffer, offset, count, cancellationToken).ConfigureAwait(false);
var stream = _stream;
if (stream == null)
{
throw new ObjectDisposedException(nameof(stream));
}
return await stream.ReadAsync(buffer, offset, count, cancellationToken).ConfigureAwait(false);
}
}
catch (ObjectDisposedException)
@@ -157,7 +164,14 @@ namespace MQTTnet.Implementations
// Workaround for: https://github.com/dotnet/corefx/issues/24430
using (cancellationToken.Register(Dispose))
{
await _stream.WriteAsync(buffer, offset, count, cancellationToken).ConfigureAwait(false);
var stream = _stream;
if (stream == null)
{
throw new ObjectDisposedException(nameof(stream));
}
await stream.WriteAsync(buffer, offset, count, cancellationToken).ConfigureAwait(false);
}
}
catch (ObjectDisposedException)