[Mono-bugs] [Bug 647948] New: null stream.BaseStream Close/Dispose not throwing exception (unlike MS .Net)
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Wed Oct 20 02:37:14 EDT 2010
https://bugzilla.novell.com/show_bug.cgi?id=647948
https://bugzilla.novell.com/show_bug.cgi?id=647948#c0
Summary: null stream.BaseStream Close/Dispose not throwing
exception (unlike MS .Net)
Classification: Mono
Product: Mono: Class Libraries
Version: 2.8.x
Platform: x86-64
OS/Version: All
Status: NEW
Severity: Minor
Priority: P5 - None
Component: System
AssignedTo: mono-bugs at lists.ximian.com
ReportedBy: htl10 at users.sourceforge.net
QAContact: mono-bugs at lists.ximian.com
Found By: ---
Blocker: ---
User-Agent: Mozilla/5.0 (X11; U; Linux; en-GB) AppleWebKit/532.4 (KHTML,
like Gecko) konqueror/4.4.5 Safari/532.4
While trying to track down some buffering problem, I wrote the following
*brain-damaged* *incorrect* code (the 4 basestream lines are wrong and
problematic and should not be there):
-------------------------------------------------------------------------------------------------
sw = new BinaryWriter(new GZipStream(new FileStream(Path.Combine(outDir,
"Carrot." + chr), FileMode.Create,
FileAccess.Write, FileShare.None), CompressionMode.Compress, true));
..
..
sw.Write(...);
sw.Write(...);
..
sw.Flush();
((GZipStream) sw.BaseStream).Flush();
((FileStream) ((GZipStream) sw.BaseStream).BaseStream).Flush();
sw.Close();
((GZipStream) sw.BaseStream).Close();
((FileStream) ((GZipStream) sw.BaseStream).BaseStream).Close();
--------------------------------------------------------------------------------------------------
Mono runtime doesn't complain; MS.Net throws exceptions about "cannot close
streams which is already closed", or "object not an instance of class".
Reproducible: Always
Actual Results:
Mono lets program run to completion.
Expected Results:
Mono should throw exception about incorrect code - trying to close the
basestream of an already closed stream is wrong. (not too sure about whether
"object not an instance of class" is the same problem - but it seems to be
about the extra casting in any case)
Mono never throw exception on this code whereas MS .NET does it almost every
time.
I know this is nitpicking, when Mono is more tolerant of bad code... this
behavior probably also depends on garbage collection and timing, but OTOH, the
fact that Mono happily runs clearly wrong code on hindsight (which MS .NET does
not run) makes it incompatible and inconvenient for cross-platform .NET
development.
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
More information about the mono-bugs
mailing list