spring-batch
spring-batch copied to clipboard
StaxEventItemReader method moveCursorToNextFragment creates an infinite loop upon retrieving endDocument event [BATCH-1878]
Martins Kazuss opened BATCH-1878 and commented
StaxEventItemReader method moveCursorToNextFragment(XMLEventReader reader)is not processing endDocument event. An infinite loop is created after retrieving this event as method is trying to find the next startElement (but as the end of the file is reached it is impossible). An example solution is provided as an attachment (CustomStaxEventItemReader which is basically the original StaxEventItemReader with modified moveCursorToNextFragment(XMLEventReader reader) method).
Attachments:
- CustomStaxEventItemReader.java (9.41 kB)
Referenced from: commits https://github.com/spring-projects/spring-batch/commit/96d3564247e85275f7bedc19b9ab7527018cc87b
1 votes, 3 watchers
Dave Syer commented
Do you have a test case? The loop terminates when reader.peek() returns null, which happens after the end element, so it looks OK to me. I added 2 test cases but the loop always terminates.
Martins Kazuss commented
As there are no issues for you, I suppose it can be some local issue. I can not provide you the context to reproduce the issue.
I suppose it may as well be removed. Anyway - if you believe that the issue should remain open, at least I need to remove the attachment.
Roman Nikolaenko commented
Hi!
I faced with this kind of issue on WebLogic 10.3.6, using org.springframework.batch version 2.1.9.RELEASE.
We have batch job that reads Domain objects from xml, then populates database with it. Everything was OK on Tomcat and Gigaspases. But when we deploy app to Weblogic, job was hanging.
Looks like Weblogic has its own implementation of jaxb-api, that is why this bug could be reproduced only there. Also it seems to me that peek() method of Weblogic XMLEventReader implementation return EndDocumentEvent when reach end of file.
Attachment file fixed the problem. I used CustomStaxEventItemReader instead StaxEventItemReader.
Thanks.
Thank you for opening the issue. Can you retry with the latest release of Spring Batch and report back the results?