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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • 2.7.0
    • 2.7.1
    • GridFS
    • None
    • .NET Standard 2+

    Description

      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.

       

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: