org.apache.cxf.interceptor.StaxOutInterceptor uses StAX API incorrectly
-----------------------------------------------------------------------
Key: CXF-1622
URL: https://issues.apache.org/jira/browse/CXF-1622
Project: CXF
Issue Type: Bug
Components: Core
Affects Versions: 2.1
Reporter: Pawel Lipka
Method StaxOutInterceptor.handleMessage(Message msg) calls
javax.xml.stream.XMLStreamWriter.writeStartDocument(String) assuming that the
string arg denotes the xml encoding while the StAX javadoc says it denotes the
xml version. There's another variant that has two inputs
javax.xml.stream.XMLStreamWriter.writeStartDocument(String encoding, String
version) that should be used instead.
The snippet below highlights the erroneous api call:
{code}
public void handleMessage(Message message) {
OutputStream os = message.getContent(OutputStream.class);
XMLStreamWriter writer = message.getContent(XMLStreamWriter.class);
if (os == null || writer != null) {
return;
}
// assert os != null;
// TODO: where does encoding constant go?
String encoding = getEncoding(message);
try {
writer = getXMLOutputFactory(message).createXMLStreamWriter(os,
encoding);
if
(Boolean.TRUE.equals(message.getContextualProperty(FORCE_START_DOCUMENT))) {
writer.writeStartDocument(encoding);
/*<=====================================================================THIS IS
THE ERRONEOUS API CALL*/
}
} catch (XMLStreamException e) {
throw new Fault(new
org.apache.cxf.common.i18n.Message("STREAM_CREATE_EXC", BUNDLE), e);
}
message.setContent(XMLStreamWriter.class, writer);
// Add a final interceptor to write end elements
message.getInterceptorChain().add(ending);
}
{code}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.