JDK-7141826 : Discrepancy between the methods hasNext() and next() in XMLEventReader
  • Type: Bug
  • Component: xml
  • Sub-Component: javax.xml.stream
  • Affected Version: 7u4
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • OS: windows_7
  • CPU: generic
  • Submitted: 2012-02-01
  • Updated: 2014-07-03
  • Resolved: 2012-02-10
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7u6Resolved
Related Reports
Relates :  
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.
10-02-2012