Details
Backports
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8219374 | 11-pool | Aleksej Efimov | P3 | Open | Unresolved |
Description
A DESCRIPTION OF THE PROBLEM :
According to the JavaDoc 11 it is allowed to use null as argument to XMLStreamWriter.setDefaultNamespace():
"Parameters:
uri - the uri to bind to the default namespace, may be null"
Since Java 8 the implementation within the subsequently called method 'isDefaultNamespace()' changed from:
if (uri == defaultNamespace) {
return true;
}
to:
if (uri.equals(defaultNamespace)) {
return true;
}
In cases where 'uri' is null the call of 'equals()' leads to a NullPointerException.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
XMLOutputFactory outFactory = XMLOutputFactory.newFactory();
outFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, new Boolean(true));
BufferedOutputStream bufferedStream = new BufferedOutputStream(outStream);
XMLStreamWriter xsw = outFactory.createXMLStreamWriter(bufferedStream, "UTF-8");
xsw.setDefaultNamespace(null);
ACTUAL -
Caused by: java.lang.NullPointerException
at java.xml/com.sun.xml.internal.stream.writers.XMLStreamWriterImpl.isDefaultNamespace(XMLStreamWriterImpl.java:1733)
at java.xml/com.sun.xml.internal.stream.writers.XMLStreamWriterImpl.setDefaultNamespace(XMLStreamWriterImpl.java:458)
According to the JavaDoc 11 it is allowed to use null as argument to XMLStreamWriter.setDefaultNamespace():
"Parameters:
uri - the uri to bind to the default namespace, may be null"
Since Java 8 the implementation within the subsequently called method 'isDefaultNamespace()' changed from:
if (uri == defaultNamespace) {
return true;
}
to:
if (uri.equals(defaultNamespace)) {
return true;
}
In cases where 'uri' is null the call of 'equals()' leads to a NullPointerException.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
XMLOutputFactory outFactory = XMLOutputFactory.newFactory();
outFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, new Boolean(true));
BufferedOutputStream bufferedStream = new BufferedOutputStream(outStream);
XMLStreamWriter xsw = outFactory.createXMLStreamWriter(bufferedStream, "UTF-8");
xsw.setDefaultNamespace(null);
ACTUAL -
Caused by: java.lang.NullPointerException
at java.xml/com.sun.xml.internal.stream.writers.XMLStreamWriterImpl.isDefaultNamespace(XMLStreamWriterImpl.java:1733)
at java.xml/com.sun.xml.internal.stream.writers.XMLStreamWriterImpl.setDefaultNamespace(XMLStreamWriterImpl.java:458)
Attachments
Issue Links
- backported by
-
JDK-8219374 XMLStreamWriter setDefaultNamespace(null) throws NullPointerException
-
- Open
-