On Sat, 2006-03-04 at 16:26 +0100, Mark Wielaard wrote:
> I cannot really see a good way to make eclipse happy. It clearly expects
> that if it throws this SAXException from startElement() that it will get
> this exception back as if nothing happened. But since it has just
> destroyed our parser so we should indeed report a SAXParserException to
> it (through the errorHandler).

Thought a bit more about it and the following seems appropriate:

2006-03-04  Mark Wielaard  <[EMAIL PROTECTED]>

    * gnu/xml/stream/SAXParser.java (parse(InputSource)): Ignore
    exceptions thrown by handlers while cleaning up and rethrow original
    exception.

I checked with Christian that it solves the problem. So I am going to
commit this later and create the release branch, unless someone
complains loudly soon. (We can always fix it in a more appropriate way
if this is really too ugly for the next release.)

Cheers,

Mark
Index: gnu/xml/stream/SAXParser.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/xml/stream/SAXParser.java,v
retrieving revision 1.19
diff -u -r1.19 SAXParser.java
--- gnu/xml/stream/SAXParser.java	3 Mar 2006 12:30:59 -0000	1.19
+++ gnu/xml/stream/SAXParser.java	4 Mar 2006 17:54:38 -0000
@@ -657,17 +657,26 @@
       }
     catch (Exception e)
       {
-        if (!startDocumentDone && contentHandler != null)
-          contentHandler.startDocument();
         SAXParseException e2 = new SAXParseException(e.getMessage(), this);
         e2.initCause(e);
-        if (errorHandler != null)
-          errorHandler.fatalError(e2);
-        if (contentHandler != null)
-          contentHandler.endDocument();
+        try
+          {
+            if (!startDocumentDone && contentHandler != null)
+              contentHandler.startDocument();
+            if (errorHandler != null)
+              errorHandler.fatalError(e2);
+            if (contentHandler != null)
+              contentHandler.endDocument();
+          }
+        catch (SAXException sex)
+          {
+            // Ignored, we will rethrow the original exception.
+          }
         reset();
         if (opened)
           in.close();
+        if (e instanceof SAXException)
+          throw (SAXException) e;
         if (e instanceof IOException)
           throw (IOException) e;
         else

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to