[jdom-interest] Bug in SAXHandler
Laurent Bihanic
laurent.bihanic at atosorigin.com
Tue Apr 10 01:51:20 PDT 2001
Hi,
For some tests, I use SAXHandler to process the output of SAXOutputter. It
used to work OK but since I got a CVS snapshot two days ago, it fails with the
following exception:
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1503)
at org.jdom.input.SAXHandler.startElement(SAXHandler.java:277)
at org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:575)
at org.jdom.output.SAXOutputter.startElement(SAXOutputter.java:470)
at org.jdom.output.SAXOutputter.element(SAXOutputter.java:385)
at org.jdom.output.SAXOutputter.elementContent(SAXOutputter.java:524)
at org.jdom.output.SAXOutputter.element(SAXOutputter.java:388)
at org.jdom.output.SAXOutputter.output(SAXOutputter.java:236)
It seems the problem arises because SAXHandler expects someone to perform
string interning (it tests for two strings being different using != (line
276)) but apparently SAXOutputter does not intern strings.
I haven't followed the intern thread in the past weeks so I don't know whether
SAXOutputter is expected to perform interning. So I've changed line 276 of
SAXHandler to:
if ((attLocalName != attQName) &&
(!attLocalName.equals(attQName))) {
Laurent
More information about the jdom-interest
mailing list