Download
Abstract
The IBM StAX serializer closes the OutputStream when XMLStreamWriter.close() is called
Download Description
PK94355 resolves the following problem:
ERROR DESCRIPTION:
The javax.xml.stream.XMLStreamWriter close() method closes the OutputStream which is not the correct behavior.
Example:
XMLOutputFactory xOF = XMLOutputFactory.newInstance();
OutputStream oStr = new FileOutputStream("c:/temp/temp.txt");
XMLStreamWriter xSW = xOF.createXMLStreamWriter(oStr);
xSW.writeStartDocument();
xSW.writeStartElement("foo");
xSW.writeCharacters("bar");
xSW.writeEndElement();
xSW.writeEndDocument();
xSW.close(); // this will close oStr.
oStr.write("\n\nMore Stuff\n".getBytes()); // exception thrown
LOCAL FIX:
None
PROBLEM SUMMARY
USERS AFFECTED:
All IBM WebSphere Application Server users of StAX.
PROBLEM DESCRIPTION:
The IBM StAX serializer closes the OutputStream when XMLStreamWriter.close() is called
RECOMMENDATION:
Install a fix pack that contains this APAR.
The IBM javax.xml.stream.XMLStreamWriter close() method closes the OutputStream which is not the correct behavior. The StAX specification clearly states that this method is not allowed to close the underlying OutputStream.
Example:
XMLOutputFactory xOF = XMLOutputFactory.newInstance();
OutputStream oStr = new FileOutputStream("c:/temp/temp.txt");
XMLStreamWriter xSW = xOF.createXMLStreamWriter(oStr);
xSW.writeStartDocument();
xSW.writeStartElement("foo");
xSW.writeCharacters("bar");
xSW.writeEndElement();
xSW.writeEndDocument();
xSW.close(); // this will close oStr.
oStr.write("More Stuff".getBytes()); // exception thrown
The exception thrown depends on the type of OutputStream and the operation performed on it. One possibility is java.io.IOException.
PROBLEM CONCLUSION:
When close() is called on the IBM XMLStreamWriter it was also closing the underlying OutputStream. This behaviour was not conformant to the StAX specification which clearly states that a call to the close() method will not close the underlying OutputStream.
The XMLStreamWriter was fixed so that it will no longer close the application's OutputStream.
APAR PK94355 is currently targeted for inclusion in Service Level (Fix Pack) 6.1.0.31 of WebSphere Application Server V6.1.
Prerequisites
Please download the UpdateInstaller below to install this fix.
Installation Instructions
Please review the readme.txt for detailed installation instructions.
Technical Support
Contact IBM Support using SR (http://www.ibm.com/software/support/probsub.html), visit the WebSphere Application Server Support Web site (http://www.ibm.com/software/webservers/appserv/was/support/), or contact 1-800-IBM-SERV (U.S. only).
Problems (APARS) fixed
Was this topic helpful?
Document Information
Modified date:
07 December 2019
UID
swg24025100