Async parse of simple document fails with WFCException: Unexpected character 'd' (code 100) in epilog
See original GitHub issueThis is a test case with the simplest document I could find. The code reproducing the problem is a copy-paste of an official example with a small fix.
@Test
public void asynchronousParseSmallestDocument() throws Exception {
final String xml =
// "<?xml version=\"1.0\" encoding=\"US-ASCII\"?>" +
"<d/>" ;
final AsyncXMLInputFactory asyncXmlInputFactory = new InputFactoryImpl() ;
final AsyncXMLStreamReader< AsyncByteArrayFeeder > xmlStreamReader =
asyncXmlInputFactory.createAsyncFor( xml.getBytes( Charsets.US_ASCII ) ) ;
final AsyncByteArrayFeeder inputFeeder = xmlStreamReader.getInputFeeder() ;
byte[] xmlBytes = xml.getBytes() ;
int bufferFeedLength = 1 ;
int currentByteOffset = 0 ;
int type ;
do{
while( ( type = xmlStreamReader.next() ) == AsyncXMLStreamReader.EVENT_INCOMPLETE ) {
byte[] buffer = new byte[]{ xmlBytes[ currentByteOffset ] } ;
currentByteOffset ++ ;
inputFeeder.feedInput( buffer, 0, bufferFeedLength ) ;
if( currentByteOffset >= xmlBytes.length ) {
inputFeeder.endOfInput() ;
}
}
switch( type ) {
case XMLEvent.START_DOCUMENT :
LOGGER.debug( "start document" ) ;
break ;
case XMLEvent.START_ELEMENT :
LOGGER.debug( "start element: " + xmlStreamReader.getName() ) ;
break ;
case XMLEvent.CHARACTERS :
LOGGER.debug( "characters: " + xmlStreamReader.getText() ) ;
break ;
case XMLEvent.END_ELEMENT :
LOGGER.debug( "end element: " + xmlStreamReader.getName() ) ;
break ;
case XMLEvent.END_DOCUMENT :
LOGGER.debug( "end document" ) ;
break ;
default :
break ;
}
} while( type != XMLEvent.END_DOCUMENT ) ;
xmlStreamReader.close() ;
}
This is what I get:
15:23:41.388 DEBUG [main] c.o.s.m.c.x.SingleContactXmlParserTest - start document
15:23:41.394 DEBUG [main] c.o.s.m.c.x.SingleContactXmlParserTest - start element: d
15:23:41.394 DEBUG [main] c.o.s.m.c.x.SingleContactXmlParserTest - end element: d
com.fasterxml.aalto.WFCException: Unexpected character 'd' (code 100) in epilog (unbalanced start/end tags?)
at [row,col {unknown-source}]: [1,7]
at com.fasterxml.aalto.in.XmlScanner.reportInputProblem(XmlScanner.java:1333)
at com.fasterxml.aalto.in.XmlScanner.throwUnexpectedChar(XmlScanner.java:1498)
at com.fasterxml.aalto.in.XmlScanner.reportPrologUnexpChar(XmlScanner.java:1358)
at com.fasterxml.aalto.async.AsyncByteArrayScanner.nextFromProlog(AsyncByteArrayScanner.java:1068)
at com.fasterxml.aalto.stax.StreamReaderImpl.next(StreamReaderImpl.java:802)
at com.otcdlink.server.model.contact.xml.SingleContactXmlParserTest.asynchronousParseSmallestDocument(SingleContactXmlParserTest.java:102)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
I’m using aalto-xml 1.0.
Issue Analytics
- State:
- Created 6 years ago
- Comments:12 (5 by maintainers)
Top Results From Across the Web
Unexpected character ('d' (code 100)): was expecting comma ...
org.codehaus.jackson.JsonParseException: Unexpected character ('d' (code 100)): was expecting comma to separate OBJECT entries\n · Ask Question.
Read more >[Solved] Encountered unexpected character '<'. - CodeProject
Sometimes this error occurs if you are returning XML strings. I too had a similar problem returning XML as string.
Read more >Unexpected character encountered while parsing value - MSDN
Hello, I am evaluating DocumentDB as backend for our new project and following MS Documentation, wrote a simple code.
Read more >Text Search Engine reason codes - IBM
Text Search Engine can produce error codes and reasons for the error. 0: Operation performed successfully - no error occurred.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@aamalik Thank you for sharing! And yes, I understand no one asks questions to annoy. Nor should it, it’s just that across many repos it sometimes feels questions are asked without reading the full thread. And it is difficult to also know how difficult they are to follow. So frustration I had was more general; apologies for directing it to you and others here.
But the important thing is that there is more information now, and error handling in
1.1.0
is better to also help recognizing the issue. Thank you everyone in helping us get there.Standalone Runnable Java Code incase somebody wants async xml file reading.