-
Bug
-
Resolution: Fixed
-
P4
-
6u11
-
h1164
-
generic
-
generic
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2185494 | 7 | Joe Wang | P3 | Closed | Fixed | m05 |
JDK-2182547 | 6u18 | Joe Wang | P4 | Resolved | Fixed | b02 |
OPERATING SYSTEM
----------------
Windows
FULL JDK VERSION
----------------
StAX in JDK 1.6.0_11
DESCRIPTION
-----------
It appears the StAX XMLOutputFactory createXMLStreamWriter(javax.xml.transform.Result) only supports Stream Results.
However, this is neither documented nor enforced. I've attached BadResultTest.java which creates an XMLStreamWriter from a SAXResult. As documented in the test case, writing to thisnew XMLStreamWriter will result in a NullPointerException.
TESTCASE SOURCE
---------------
import javax.xml.stream.XMLEventWriter;
import javax.xml.stream.XMLStreamWriter;
import javax.xml.transform.sax.SAXResult;
public class BadResultTest extends org.xml.sax.ext.DefaultHandler2 {
public static void main (String[] args) throws Exception {
javax.xml.stream.XMLOutputFactory factory = javax.xml.stream.XMLOutputFactory.newInstance ();
SAXResult saxResult= new SAXResult(new BadResultTest());
//I believe this should either store away the SAXResult
//Or throw an UnsupportedOperationException
//Clearly, it's expecting an Outputstream, which doesn't exist in the SAXResult
XMLStreamWriter writer = factory.createXMLStreamWriter (saxResult);
//tries to write to non-existant stream and throws NullPointerException
writer.writeStartDocument ();
System.out.println("Success");
}
}
----------------
Windows
FULL JDK VERSION
----------------
StAX in JDK 1.6.0_11
DESCRIPTION
-----------
It appears the StAX XMLOutputFactory createXMLStreamWriter(javax.xml.transform.Result) only supports Stream Results.
However, this is neither documented nor enforced. I've attached BadResultTest.java which creates an XMLStreamWriter from a SAXResult. As documented in the test case, writing to thisnew XMLStreamWriter will result in a NullPointerException.
TESTCASE SOURCE
---------------
import javax.xml.stream.XMLEventWriter;
import javax.xml.stream.XMLStreamWriter;
import javax.xml.transform.sax.SAXResult;
public class BadResultTest extends org.xml.sax.ext.DefaultHandler2 {
public static void main (String[] args) throws Exception {
javax.xml.stream.XMLOutputFactory factory = javax.xml.stream.XMLOutputFactory.newInstance ();
SAXResult saxResult= new SAXResult(new BadResultTest());
//I believe this should either store away the SAXResult
//Or throw an UnsupportedOperationException
//Clearly, it's expecting an Outputstream, which doesn't exist in the SAXResult
XMLStreamWriter writer = factory.createXMLStreamWriter (saxResult);
//tries to write to non-existant stream and throws NullPointerException
writer.writeStartDocument ();
System.out.println("Success");
}
}
- backported by
-
JDK-2182547 StAX XMLOutputFactory createXMLStreamWriter() only supports Stream Results
-
- Resolved
-
-
JDK-2185494 StAX XMLOutputFactory createXMLStreamWriter() only supports Stream Results
-
- Closed
-