You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The issue can be reproduced by (I attach test.txt):
WstxInputFactory inputFactory = new WstxInputFactory();
WstxOutputFactory outputFactory = new WstxOutputFactory();
String text = FileUtils.readFileToString(new File("test.txt"), "UTF-8");
ByteArrayOutputStream bios = new ByteArrayOutputStream();
try {
XMLStreamReader2 reader = (XMLStreamReader2) inputFactory.createXMLStreamReader(new StringReader(text));
XMLStreamWriter2 writer = (XMLStreamWriter2) outputFactory.createXMLStreamWriter(bios, "UTF-8");
while (reader.hasNext()) {
reader.next();
writer.copyEventFromReader(reader, false);
}
} catch (Exception e) {
e.printStackTrace();
}
and produces:
java.lang.ArrayIndexOutOfBoundsException: -1
at com.ctc.wstx.sr.BasicStreamReader.readAndWriteText(BasicStreamReader.java:5185)
at com.ctc.wstx.sr.BasicStreamReader.getText(BasicStreamReader.java:1431)
at com.ctc.wstx.sw.BaseStreamWriter.copyEventFromReader(BaseStreamWriter.java:857)
at test.WoodstoxTest.main(WoodstoxTest.java:27)
To produce the issue all of the following seem to need to be true:
copyEventFromReader is called with a second parameter of false rather than true
Turns out to be another boundary condition; also required use of \r as linefeed (MacOS I think?) to trigger. Fixed, will be in 6.0.3 once I release that (might be time to do it tonight, 3rd fix).
Thanks for the quick fix and release. I hadn't actually noticed that \r was being used to indicate new lines!
\r was used by legacy versions of MacOS, but current versions use \n.
Ah. Makes sense that Macs have switched, perhaps with MacOS X when switching to unix kernel... I just remembered that once upon a time something was using \r. And XML definitely supports 3 linefeed combinations (\n, \r, \r\n).
The issue can be reproduced by (I attach test.txt):
and produces:
To produce the issue all of the following seem to need to be true:
test.txt
EDIT: I reproduced this issue on Woodstox 4.4.1 and 6.0.2
The text was updated successfully, but these errors were encountered: