-
Bug
-
Resolution: Fixed
-
P4
-
8, 9, 10, 11
-
b01
-
Not verified
A DESCRIPTION OF THE PROBLEM :
In the Javadoc for XMLStreamReader.next() there are two references to a hasNext() method when it returns false.
(a) "This method will throw an IllegalStateException if it is called after hasNext() returns false"
(b) "Throws: NoSuchElementException - if this is called when hasNext() returns false
The effect is that it is unclear what should happen when there are no more events to return. The state table in the class-level Javadoc states (i) that next() is not a valid method to call in END_DOCUMENT state, and (ii) that in such circumstances, IllegalStateException should be thrown. However, the "throws" documentation for next() suggests that the method can throw NoSuchElementException.
I have not attempted to check the behaviour of existing implementations of the interface, since there are multiple implementations I'm not sure this would be useful.
In the Javadoc for XMLStreamReader.next() there are two references to a hasNext() method when it returns false.
(a) "This method will throw an IllegalStateException if it is called after hasNext() returns false"
(b) "Throws: NoSuchElementException - if this is called when hasNext() returns false
The effect is that it is unclear what should happen when there are no more events to return. The state table in the class-level Javadoc states (i) that next() is not a valid method to call in END_DOCUMENT state, and (ii) that in such circumstances, IllegalStateException should be thrown. However, the "throws" documentation for next() suggests that the method can throw NoSuchElementException.
I have not attempted to check the behaviour of existing implementations of the interface, since there are multiple implementations I'm not sure this would be useful.
- csr for
-
JDK-8206084 Clarify that XMLStreamReader.next() throws NoSuchElementException when hasNext() is false
-
- Closed
-