Skip to content

Commit 1446eac

Browse files
authored
CSHARP-4377: Flush on read-only stream should be a NOP. (#971)
1 parent e201525 commit 1446eac

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/MongoDB.Driver.GridFS/GridFSDownloadStreamBase.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,13 @@ public override void Close(CancellationToken cancellationToken)
100100

101101
public override void Flush()
102102
{
103-
throw new NotSupportedException();
103+
// CSHARP-4377: Flush on read-only stream should be a NOP
104104
}
105105

106106
public override Task FlushAsync(CancellationToken cancellationToken)
107107
{
108-
throw new NotSupportedException();
108+
// CSHARP-4377: Flush on read-only stream should be a NOP
109+
return Task.CompletedTask;
109110
}
110111

111112
public override void SetLength(long value)

tests/MongoDB.Driver.GridFS.Tests/GridFSDownloadStreamBaseTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public void FileInfo_should_return_expected_result()
220220

221221
[Theory]
222222
[ParameterAttributeData]
223-
public void Flush_should_throw(
223+
public void Flush_should_not_throw(
224224
[Values(false, true)] bool async)
225225
{
226226
var bucket = CreateBucket(128);
@@ -238,7 +238,7 @@ public void Flush_should_throw(
238238
action = () => subject.Flush();
239239
}
240240

241-
action.ShouldThrow<NotSupportedException>();
241+
action.ShouldNotThrow<NotSupportedException>();
242242
}
243243

244244
[Fact]

0 commit comments

Comments
 (0)