Uploaded image for project: 'Woden'
  1. Woden
  2. WODEN-125

QName.valueOf behaviour does not match the Javadoc



    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • None
    • Parser
    • None


      The javax.xml.namespace.QName class in Woden implements the static valueOf(String) method and the method's javadoc conforms to other QName implementation in J2EE 1.4 and Java 5.0. However, the method's implementation contain more constraints on structure and validation than are implied by the javadoc. It tries to avoid 'garbage in' (e.g. multiple left curly braces) by treating this as an error, but according to the Javadoc no such validation is required and the only criteria is that the String argument must not be null and must be in the same format as that produced by the toString() method. That is, 'garbage in' should just be accepted and used to create a QName - typically this means a 'garbage' string will form the localpart and the namespace will be the empty string. This is acceptable, because per the javadoc no validation is done on the namespace or the localpart.

      As an aside, the Woden test suite checks for this current behaviour in the valueOf method. However, when the test suite runs in a Java 5 JRE it is the Java 5 implementation of QName loaded by the classloader, not Woden's, and the test cases fail because that implementation is more lax. The AllWodenTests junit harness has a conditional statement to check the java version, but this is not really adequate as the QNameTests junit class can be invoked independently of AllWodenTests (e.g. by Maven2).

      So, the valueOf method must be 'dumbed down' to conform to the javadoc and the corresponding tests removed. A new test is needed to check the String passed to the valueOf method to create the QName object is equal to the result of the object's toString() method.




            Unassigned Unassigned
            jkaputin John Alan William Kaputin
            0 Vote for this issue
            0 Start watching this issue