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

getAttributeName throws nullpointer exception for an element without attribute

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.4.0
    • xml
    • 1.4
    • generic
    • generic
    • Verified

        While I don't see the problem reported in issue 2 in the new filtered streamreader, I did find an interesting question about these getters. I added a unit test which shows that when an element does not have attribute, in the following methods:
                            r1.getAttributeValue(0);
                            r1.getAttributeType(0);
                            r1.getAttributePrefix(0);
                            r1.getAttributeNamespace(0);
                            r1.getAttributeName(0);
        only the last would throw an exception, even so, the exception was not thrown from getAttributeName. here's the exception:
                at com.sun.xml.stream.XMLReaderImpl.convertXNIQNametoJavaxQName(XMLReaderImpl.java:1209)
                at com.sun.xml.stream.XMLReaderImpl.getAttributeName(XMLReaderImpl.java:633)
                at com.sun.xml.stream.XMLStreamFilterImpl.getAttributeName(XMLStreamFilterImpl.java:200)
                at XMLStreamFilterTest.GettersTest.checkAttributes(GettersTest.java:94)
                at XMLStreamFilterTest.GettersTest.testGetAttributes(GettersTest.java:152)

              joehw Joe Wang
              joehw Joe Wang
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: