Ebeo / google-gdata

Automatically exported from code.google.com/p/google-gdata
0 stars 0 forks source link

.NET client does not always properly dispose streams #355

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
There are many places in the code where the .NET client does not dispose 
streams, leaving them to be garbage collected.  This is problematic because 
the non-garbage collected references hold locks on the files which can cause 
havoc for code that needs to manipulate the original file after it has been 
uploaded.

In particular, ResumableUpload.Update and ResumableUpload.Insert reference 
payload.MediaSource.Data which returns a new stream on each invocation, but 
do not dispose the streams when completed.

MediaSource.ContentLength also creates streams and does not dispose them.

Finally, it is bad convention for a property (such as MediaSource.Data) to 
return a new stream each time it is referenced.  It would be clearer if this 
property were renamed to something more self-explanatory such as method named 
OpenDataStream() that clearly indicated a new stream was being created.

Original issue reported on code.google.com by bryan.murphy on 19 Mar 2010 at 8:43

GoogleCodeExporter commented 9 years ago
It's not really many. But yeah, those are bugs. I agree with the bad 
convention, i
will probably mark that thing obsolete and introduce a method to do that. 

Will fix soon.

Original comment by fman...@gmail.com on 22 Mar 2010 at 2:27

GoogleCodeExporter commented 9 years ago
Checked into subversion. Introduced GetDataStream() on Mediasource, marked the 
old one obsolete and changed 
call patterns around .Data to use the new one and use using().

Original comment by fman...@gmail.com on 23 Mar 2010 at 4:41