JDK-6219364 : com.SAXParserImpl.setProperty("feature",null) throws NullPointerException
  • Type: Bug
  • Component: xml
  • Sub-Component: org.xml.sax
  • Affected Version: 5.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2005-01-20
  • Updated: 2012-04-25
  • Resolved: 2006-12-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other JDK 6
5.0u14Fixed 6 rcFixed
Description
FULL PRODUCT VERSION :
both jdk 1.5.0 and jdk 1.5.0 update 1

ADDITIONAL OS VERSION INFORMATION :
XP sp 1

A DESCRIPTION OF THE PROBLEM :
public class SAXParserImpl extends javax.xml.parsers.SAXParser
...
    /**
     * Sets the particular property in the underlying implementation of
     * org.xml.sax.XMLReader.
     */
    public void setProperty(String name, Object value)
        throws SAXNotRecognizedException, SAXNotSupportedException
    {
...
        }else{
            xmlReader.setProperty(name, value);
            parserFeatures.put(name, value);    <-- bug line 395 jdk 1.5.0.01
        }
    }

parserFeatures is a Hashtable and throws NullPointerException when a null value is set in last line of setProperty().  parserFeatures should be a HashMap
so features can be removed.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
This crops up in AXIS 1.1 during return msg processing  when ("http://xml.org/sax/properties/lexical-handler" is set to null to "reuse" the parser in  org.apache.axis.encoding.DeserializationContextImpl

    public void parse() throws SAXException
    {
        if (inputSource != null) {
            SAXParser parser = XMLUtils.getSAXParser();
            try {
                parser.setProperty("http://xml.org/sax/properties/lexical-handler", this);
                parser.parse(inputSource, this);

                try {
                    // cleanup - so that the parser can be reused.
                    parser.setProperty("http://xml.org/sax/properties/lexical-handler", null);
                } catch (SAXException se){
                    // Ignore.
                }

                // only release the parser for reuse if there wasn't an
                // error.  While parsers should be reusable, don't trust
                // parsers that died to clean up appropriately.
                XMLUtils.releaseSAXParser(parser);
            } catch (IOException e) {
                throw new SAXException(e);
            }
            inputSource = null;
        }
    }


see
http://www.trackstudio.com/forum/bug-tracking-integrating-soap-api-issue-527.html
http://forum.java.sun.com/thread.jspa?forumID=34&threadID=560999


REPRODUCIBILITY :
This bug can be reproduced always.

CUSTOMER SUBMITTED WORKAROUND :
placing xerces-2.6.1.jar in \jdk1.5.0_01\jre\lib\ext\ fixes the problem
as does JDK 1.4.x
###@###.### 2005-1-20 04:13:05 GMT

Comments
EVALUATION null is not prohibited by the spec so should be allowed as a valid value.
10-12-2005

WORK AROUND note that for this specific use-case, reusing a parser, see reset() to restore parser to its original state.
10-12-2005

EVALUATION ###@###.### 2005-1-31 06:46:11 GMT
31-01-2005