I have found a problem in the class XMLStreamReaderToContentHandler class.
The method handleCharacters() (line 229) calls javax.xml.stream.XMLStreamReader
with the incorrect sourceStart parameter (first parameter).
The method currently calls:
staxStreamReader.getTextCharacters(textStart, chars, 0, textLength);
textStart is obtained from a call to staxStreamReader.getTextStart(). From the
Javadoc description for the method "Returns the offset into the text character
array where the first character (of this text event) is stored.". This method
can not be used as the first argument to the getTextCharacters(....) method
"sourceStart - the index of the first character in the source array to copy".
i.e. the code is trying to set the starting point for the copy as the position
in the character array for the XML chunk rather than the character array for the
The fix is to change the line to:
staxStreamReader.getTextCharacters(0, chars, 0, textLength);