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

GridFSForwardOnlyUploadStream not closing properly on .NET Standard 2+ when cast to Stream before calling Close

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 2.7.1
    • Affects Version/s: 2.7.0
    • Component/s: GridFS
    • None
    • Environment:
      .NET Standard 2+

      Consider the following code:

      var dst = bucket.OpenUploadStream(srcFile.Name);
      srcFile.OpenRead().CopyTo(dst);
      // dst.Close(); // Correctly writes fs.files collection
      ((Stream)dst).Close(); // Does NOT write to fs.files collection{{}}

      Looks like it's missing Close() override for NETSTANDARD2_0 that'll close the wrapped stream?  GridFSUploadStreamCompat.cs Line 80

      This leads to some pretty difficult to diagnose issues when the stream is used in any number of generic libraries that works against the Stream interface.

       

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            peterhuang Peter Huang
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: