[Mono-bugs] [Bug 60809][Nor] New - XmlDocument.Load with inaccessible file throws the wrong exception

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sun, 27 Jun 2004 16:16:06 -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 1@234.cx.

http://bugzilla.ximian.com/show_bug.cgi?id=60809

--- shadow/60809	2004-06-27 16:16:06.000000000 -0400
+++ shadow/60809.tmp.3440	2004-06-27 16:16:06.000000000 -0400
@@ -0,0 +1,56 @@
+Bug#: 60809
+Product: Mono: Class Libraries
+Version: unspecified
+OS: 
+OS Details: Fedora Core 2 with all current updates
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Sys.XML
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: 1@234.cx               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: XmlDocument.Load with inaccessible file throws the wrong exception
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+
+
+Steps to reproduce the problem:
+1. Download test.cs which I will attach shortly.
+2. Compile test.cs to test.exe
+3. Run test.exe
+
+Actual Results:
+
+A NullReferenceException exception is thrown.  (A traceback is displayed
+for a FileNotFoundException, but this does not actually reach my code.)
+
+Expected Results:
+
+Microsoft throw a FileNotFoundException, and I believe this is more logical.
+
+How often does this happen? 
+
+Always.
+
+Additional Information:
+
+The NullReferenceException is thrown from the try ... finally block on
+lines 595 to 601 of XmlDocument.cs.  What seems to happen is that a
+FileNotFoundException is thrown from the constructor of XmlTextReader. 
+Control then falls through to the finally clause, which attempts to close
+the XmlTextReader in spite of the fact that it was not initialised.
+
+I haven't tried it, but perhaps the problem could be solved by moving line
+596 outside the try block?  All the finally clause does is close the
+XmlTextReader, and this is not necessary if it was not opened in the first
+place.
+
+(This occurred with the release candidate.  The lines in the source file
+are also based on the code from the release candidate.)