Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8206084

Clarify that XMLStreamReader.next() throws NoSuchElementException when hasNext() is false

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 12
    • xml
    • None
    • minimal
    • There is no compatibility risk. This change removes only an incorrect statement.
    • Java API
    • SE

      Summary

      Clarifies that XMLStreamReader.next() throws NoSuchElementException when hasNext() is false

      Problem

      XMLStreamReader.next() specified in the throw statement that NoSuchElementException should be thrown when hasNext() returns false . However, it also contained an unnecessary statement in a note of the general specification that IllegalStateException will be thrown in the situation.

      Solution

      Remove the statement that stated IllegalStateException will be thrown.

      Specification

      javax.xml.stream.XMLStreamReader

      NOTE: empty element (such as <tag/>) will be reported with two separate events: START_ELEMENT, 
      - END_ELEMENT - This preserves parsing equivalency of empty element to <tag></tag>. This method 
      - will throw an IllegalStateException if it is called after hasNext() returns false. 
      + END_ELEMENT - This preserves parsing equivalency of empty element to <tag></tag>. 

            joehw Joe Wang
            webbuggrp Webbug Group
            Lance Andersen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: