United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6472982 javax.xml.namespace.NamespaceContext.getPrefix("") should not throw IllegalArgumentException
JDK-6472982 : javax.xml.namespace.NamespaceContext.getPrefix("") should not throw IllegalArgumentException

Details
Type:
Bug
Submit Date:
2006-09-20
Status:
Closed
Updated Date:
2012-04-25
Project Name:
JDK
Resolved Date:
2010-01-15
Component:
xml
OS:
generic
Sub-Component:
javax.xml.stream
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
6
Fixed Versions:
1.4.0 (h1192)

Related Reports

Sub Tasks

Description
Consider the following piece of code:
XMLStreamReader reader= ...;
NamespaceContext context = reader.getNamespaceContext();
context.getPrefix(""); // <-- this throws an IllegalArgumentException

The javadocs for NamespaceContext do not agree that NamespacePrefix#getPrefix() should throw an IllegalArgumentException for "".  An exception is thrown only for a null argument.  The javadocs contain the following table that describes this:
*getPrefix(namespaceURI)** return value for specified Namespace URIs*
*Namespace URI parameter*
    *prefix value returned*
<default Namespace URI>     XMLConstants.DEFAULT_NS_PREFIX ("")
bound Namespace URI     prefix bound to Namespace URI in the current scope, if multiple prefixes are bound to the Namespace URI in the current scope, a single arbitrary prefix, whose choice is implementation dependent, is returned
unbound Namespace URI     null
XMLConstants.XML_NS_URI ("http://www.w3.org/XML/1998/namespace") XMLConstants.XML_NS_PREFIX ("xml")
XMLConstants.XMLNS_ATTRIBUTE_NS_URI ("http://www.w3.org/2000/xmlns/") XMLConstants.XMLNS_ATTRIBUTE ("xmlns")
null     IllegalArgumentException is thrown

Based on this table, the empty string should be treated as an unbound namespace URI and the prefix returned should be null. 

This bug was submitted by IBM as a part of their challenge regarding StAX test presented in JAXP TCK and JCK.

The bug exists in JDK 6 b98 and JAXP RI 1.4 b38.

                                    

Comments
EVALUATION

Fixed in JAXP sources. Note that this is a reverse of the change in 5055532, a test from 5055532 has been deprecated.
                                     
2010-01-15
EVALUATION

ChangeSet=http://hg.openjdk.java.net/jdk6/jdk6/jaxp/rev/5c070921580c,ChangeRequest=6923146,ChangeRequest=6917454,ChangeRequest=6472982,ChangeRequest=6909759,ChangeRequest=6333993,ChangeRequest=6900779,ChangeRequest=6900773,ChangeRequest=6900249,ChangeRequest=6675332,ChangeRequest=6889654,ChangeRequest=6889649,ChangeRequest=6863312
                                     
2010-02-18



Hardware and Software, Engineered to Work Together