Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-4377

GridFSDownloadStream.Flush must not throw NotSupportedException

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 2.19.0
    • Affects Version/s: None
    • Component/s: GridFS
    • None
    • Minor Change

      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.

            Assignee:
            james.kovacs@mongodb.com James Kovacs
            Reporter:
            rhmboerdijk@gmail.com Robin Boerdijk
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: