United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 7141826 Discrepancy between the methods hasNext() and next() in XMLEventReader
7141826 : Discrepancy between the methods hasNext() and next() in XMLEventReader

Details
Type:
Bug
Submit Date:
2012-02-01
Status:
Closed
Updated Date:
2012-04-25
Project Name:
JDK
Resolved Date:
2012-02-10
Component:
xml
OS:
windows_7
Sub-Component:
javax.xml.stream
CPU:
generic
Priority:
P3
Resolution:
Not an Issue
Affected Versions:
7u4
Fixed Versions:
7u6

Related Reports
Relates:

Sub Tasks

Description
During testing we found the case where the method next () and hasNext () do not corresponded to each other. Method  hasNext() returns true, but the method of next() throws NoSuchElementException.
May be xml file is wrong because of the line separator is \r\n , but in any case, the behavior of these methods must match. In the case of a file with the correct line separator(\n) it works properly.

                                    

Comments
EVALUATION

This is not an issue in StAX. Parsing the xml file with SAX or DOM, you'd see an error was actually returned by the entity scanner. What's missing in StAX was the cause of the exception. I've created a change request 7144423 to fix the problem.

The real error was "Invalid byte 3 of 3-byte UTF-8 sequence" which was first encountered in the PI section. Note that if you create the test xml file by copy-n-paste and then save in Windows 7 like I did, those invalid sequence unacceptable to the UTF8Reader would be gone and the test would pass.
                                     
2012-02-10



Hardware and Software, Engineered to Work Together