Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
XMLReaders creates XSDVALIDATING unnecessarily #136
I investigated a performance regression in our application when upgrading to JDOM2 : calling new SAXBuilder() for the first time went from 15ms to 700ms. It turns out that it calls XMLReaders.NONVALIDATING and since XMLReaders is an enum it also constructs the other members. And XSDVALIDATING takes a long time when xerces 2.9.1 is in the classpath. So even though we're never going to validate anything using XSD we're forced to take a 700ms hit (short of patching Xerces).
I've patched XMLReaders today (June, 26th 2014) to try to address the aforementioned problems. ant junit only reports 3 errors for TestStAXOutputter2Writer and TestStAXReader2Writer.
Thougths about the patch : perhaps the NONVALIDATING and DTDVALIDATING fields should also be encapsulated. XMLReaders shouldn't be plural.
I only use XMLReaders indirectly through SAXBuilder, so another solution is to create new constants (for no validation and DTD validation) to use in SAXBuilder constructors. My main point is to only initialize XSD validation if needed. That being said you should at least synchronize access to jaxpfactory.