Summary
The Flush method of GridFSDownloadStream throws NotSupportedException. This is incorrect according to the .NET System.IO.Stream.Flush man page at https://learn.microsoft.com/en-us/dotnet/api/system.io.stream.flush?view=net-6.0.
The man page states: "In a class derived from Stream that doesn't support writing, Flush is typically implemented as an empty method to ensure full compatibility with other Stream types since it's valid to flush a read-only stream."
See below for a real-life case where this is a problem
Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).
2.17.1
How to Reproduce
Pass a GridFSDownloadStream as input stream to a .NET CryptoStream in read mode. The CryptoStream's Dispose() method calls Flush() on the input stream, which causes the NotSupportedException to be thrown.
Additional Background
Please provide any additional background information that may be helpful in diagnosing the bug.
- is related to
-
CSHARP-1488 Properly implement Flush/FlushAsync for GridFS streams
- Closed