Re: Strange exception when running checkstyle

Mark Wielaard <[email protected]>
Newsgroups gmane.comp.java.classpath.extensions.xml
Message-ID <[email protected]>
Hi,

On Tue, 2004-12-28 at 18:40 +0100, Michael Koch wrote:
> Am Dienstag, 28. Dezember 2004 09:16 schrieb Mark Wielaard:
> 
> > Removing these two warnings made Checkstyle work just fine:
> > [...]
>
> I think its GNU Jaxp's fault is it works with jamvm/classpath/Xalan 
> and SUN JDK 1.4.2 as is.

No. That is a bogus argument. Xalan and the Sun implementation
apparently don't give a warning in this situation. But the real bug is
that Checkstyle installs an ErrorHandler that doesn't handle warnings
properly/nicely (it just throws an exception).

But since it looks like in this case the URIs are actually absolute we
can try to be a little less pedantic in that case by first checking if
this is the case and only warn if it actually isn't absolute.

Does the attached patch work for you?

Cheers,

Mark

_______________________________________________
Classpathx-xml mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpathx-xml
absolute.patch (text/x-patch, 1.9 KB)
Index: gnu/xml/aelfred2/SAXDriver.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/xml/aelfred2/SAXDriver.java,v
retrieving revision 1.1
diff -u -r1.1 SAXDriver.java
--- gnu/xml/aelfred2/SAXDriver.java	23 Dec 2004 22:38:43 -0000	1.1
+++ gnu/xml/aelfred2/SAXDriver.java	28 Dec 2004 19:41:42 -0000
@@ -645,8 +645,6 @@
 
 	try {
 	    if (baseURI == null) {
-		warn ("No base URI; hope this SYSTEM id is absolute: "
-			+ systemId);
 		return new URL (systemId).toString ();
 	    } else
 		return new URL (new URL (baseURI), systemId).toString ();
@@ -660,7 +658,12 @@
 
 	    // sometimes sysids for notations or unparsed entities
 	    // aren't really URIs...
-	    warn ("Can't absolutize SYSTEM id: " + e.getMessage ());
+	    if (baseURI == null)
+	      warn ("No base URI; and SYSTEM id (" + systemId
+		    + ") is not absolute: " + e.getMessage());
+	    else
+	      warn ("Can't absolutize baseURI (" + baseURI +
+		    ") with SYSTEM id (" + systemId + "): " + e.getMessage());
 	    return systemId;
 	}
     }
Index: gnu/xml/aelfred2/XmlParser.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/xml/aelfred2/XmlParser.java,v
retrieving revision 1.1
diff -u -r1.1 XmlParser.java
--- gnu/xml/aelfred2/XmlParser.java	23 Dec 2004 22:38:43 -0000	1.1
+++ gnu/xml/aelfred2/XmlParser.java	28 Dec 2004 19:41:43 -0000
@@ -2808,8 +2808,17 @@
 		handler.verror ("SYSTEM id has a URI fragment: " + ids [1]);
 	    ids [2] = handler.getSystemId ();
 	    if (ids [2] == null)
-		handler.warn ("No base URI; hope URI is absolute: "
-			+ ids [1]);
+	      {
+		try
+		  {
+		    new URL(ids[1]);
+		  }
+		catch (MalformedURLException mue)
+		  {
+		    handler.warn("No base URI; and URI (" + ids[1]
+				 + " is not absolute: " + mue.getMessage());
+		  }
+	      }
 	}
 
 	return ids;
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQBB0be5xVhZCJWr9QwRAjfqAJ9W9YQ5yjmwMiqFiK5r32x9qdaITgCeMZEE
gumKS0QUcgdWQ4ma1j+QAow=
=zTTa
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.