-
Bug
-
Resolution: Fixed
-
P3
-
9, 10, 11, 12
-
b06
-
x86_64
-
windows_7
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8219374 | 11.0.23-oracle | Ravi Reddy | P3 | Resolved | Fixed | b01 |
JDK-8322189 | 11.0.23 | Amos SHI | P3 | Resolved | Fixed | b01 |
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)
- backported by
-
JDK-8219374 XMLStreamWriter setDefaultNamespace(null) throws NullPointerException
-
- Resolved
-
-
JDK-8322189 XMLStreamWriter setDefaultNamespace(null) throws NullPointerException
-
- Resolved
-