[CSHARP-2373] GridFSForwardOnlyUploadStream not closing properly on .NET Standard 2+ when cast to Stream before calling Close Created: 01/Sep/18  Updated: 28/Oct/23  Resolved: 31/Oct/18

Status: Closed
Project: C# Driver
Component/s: GridFS
Affects Version/s: 2.7.0
Fix Version/s: 2.7.1

Type: Bug Priority: Major - P3
Reporter: Peter Huang Assignee: Robert Stam
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

.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.

 



 Comments   
Comment by Githook User [ 06/Nov/18 ]

Author:

{'name': 'rstam', 'email': 'robert@robertstam.org', 'username': 'rstam'}

Message: CSHARP-2373: GridFSForwardOnlyUploadStream not closing properly on .NET Standard 2+ when cast to Stream before calling Close.
Branch: v2.7.x
https://github.com/mongodb/mongo-csharp-driver/commit/bc07e5fcb432239279cf790ad41d7d61e33a745c

Comment by Githook User [ 31/Oct/18 ]

Author:

{'name': 'rstam', 'email': 'robert@robertstam.org', 'username': 'rstam'}

Message: CSHARP-2373: GridFSForwardOnlyUploadStream not closing properly on .NET Standard 2+ when cast to Stream before calling Close.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/0685c54c50c36b2e9f9937100060c507df1b232c

Generated at Wed Feb 07 21:42:22 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.