Skip to Content.
Sympa Menu

xom-interest - [XOM-interest] Bug in XOM - Static block in Verifier class

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Oliver Geisser <oliver.geisser AT gmx.de>
  • To: xom-interest AT lists.ibiblio.org
  • Subject: [XOM-interest] Bug in XOM - Static block in Verifier class
  • Date: Wed, 12 May 2004 20:32:49 +0200

Hi

I think I've found an bug in XOM or at least
an not so clean error detection in class
"nu.xom.Verifier".

I have made comments to the source code to make
the problem clear. My comments starts with "OG"

static {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
if (loader == null) loader = Verifier.class.getClassLoader();
if (loader == null) throw new RuntimeException(
"Verifier couldn't find the right ClassLoader!");

//OG if we are here the exists a classloader
//OG but what if the classloader does not find
//OG the resource file?
//OG In this case the return of getResourceAsStream is null
//OG This happened for me with the Eclipse 3.0 M8
//OG runtime system which has own/special classloaders
DataInputStream in = new DataInputStream(
loader.getResourceAsStream("nu/xom/characters.dat"));
try {
in.readFully(flags);
}
catch (IOException ex) { //OG I think this is the bug
//OG there should also be a catch for a NullPointerException
//OG without it the client does not get the correct error message
throw new RuntimeException("Broken XOM installation: "
+ "could not load nu/xom/characters.dat");
}
finally {
try {
//OG if there is a NullPointerException above
//OG then here we will get here a NPE again
in.close();
}
catch (IOException ex) { // and again it will not be catched
//OG this time this is ok because it's a real RuntimeError
//OG but the Error message is not clear for the client
// no big deal
}
}
}

Hope this helps. Thanks for a great library

Olli





  • [XOM-interest] Bug in XOM - Static block in Verifier class, Oliver Geisser, 05/12/2004

Archive powered by MHonArc 2.6.24.

Top of Page