[Mono-bugs] [Bug 65918][Nor] New - Regression: ObjectDisposedException when calling XmlTextWriter.Close() twice

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Tue, 14 Sep 2004 02:44:25 -0400 (EDT)

Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by gert.driesen@pandora.be.


--- shadow/65918	2004-09-14 02:44:25.000000000 -0400
+++ shadow/65918.tmp.19648	2004-09-14 02:44:25.000000000 -0400
@@ -0,0 +1,54 @@
+Bug#: 65918
+Product: Mono: Class Libraries
+Version: unspecified
+OS Details: 
+Status: NEW   
+Priority: Normal
+Component: Sys.XML
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: gert.driesen@pandora.be               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+Summary: Regression: ObjectDisposedException when calling XmlTextWriter.Close() twice
+Recent modifications made to XmlTextWriter, changed the behaviour when the
+XmlTextWriter is closed.
+When invoking Close() on an XmlTextWriter the underlying StreamWriter is
+now both Flushed and Closed,  While only Close should be called. When
+StreamWriter.Close() is called, a flush will be performed anyway.
+As a side-effect of calling both Close and Flush on the StreamWriter, an
+ObjectDisposedException is thrown when calling Close twice on the
+XmlTextWriter (as the Flush call will throw an ObjectDisposedException the
+second time).
+When you compile and execute the following code :
+using System.IO;
+using System.Text;
+using System.Xml;
+public class EntryPoint {
+  public static void Main() {
+    XmlTextWriter writer = new XmlTextWriter("test.xml", Encoding.UTF8);  
+    writer.Close();
+    writer.Close();
+  }
+The following exception is thrown on Mono :
+Unhandled Exception: System.ObjectDisposedException: The object was used
+after being disposed.
+in <0x00035> System.IO.StreamWriter:Flush ()
+in <0x0001c> System.Xml.XmlTextWriter:Close ()
+in <0x0004a> EntryPoint:Main ()
+Running the same code on MS.NET works fine.