You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Freeman Fang (JIRA)" <ji...@apache.org> on 2017/09/28 04:59:00 UTC
[jira] [Commented] (CXF-7520) Ensure CXF can build with JDK9
GA(build 9+181)
[ https://issues.apache.org/jira/browse/CXF-7520?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16183662#comment-16183662 ]
Freeman Fang commented on CXF-7520:
-----------------------------------
So far I disable two tests when run with jdk9 GA
JSONProviderTest.testWriteNullValueAsString
JSONProviderTest.testWriteNullValueAsNull
Because those two are caused by a JDK9 bug IMO. Already reported to [1]
This is caused by a new introduced com.sun.xml.internal.bind.v2.runtime.output.XMLStreamWriterOutput$NewLineEscapeHandler
Previously the
com.sun.xml.internal.bind.v2.runtime.output.XMLStreamWriterOutput.text method is
{code}
public void text(String value, boolean needsSeparatingWhitespace) throws IOException, SAXException, XMLStreamException {
if(needsSeparatingWhitespace)
out.writeCharacters(" ");
out.writeCharacters(value);
}
{code}
So that even the String value is empty, the underlying XMLStreamWriter get chance to be invoked, so that we can do anything in customized XMLStreamWriter like JSONProviderTest$NullWriter we handle the case that the value is empty and put anything meaningful in the output payload
However with JDK9 GA the com.sun.xml.internal.bind.v2.runtime.output.XMLStreamWriterOutput.text method is
{code}
public void text(String value, boolean needsSeparatingWhitespace) throws IOException, SAXException, XMLStreamException {
if(needsSeparatingWhitespace)
out.writeCharacters(" ");
escapeHandler.escape(value.toCharArray(), 0, value.length(), false, writerWrapper);
}
{code}
And the escapeHandler.escape is
{code}
public void escape(char[] ch, int start, int length, boolean isAttVal, Writer out) throws IOException {
int limit = start+length;
int lastEscaped = start;
for (int i = start; i < limit; i++) {
char c = ch[i];
if (c == '\r' || c == '\n') {
if (i != lastEscaped) {
out.write(ch, lastEscaped, i - lastEscaped);
}
lastEscaped = i + 1;
if (out instanceof XmlStreamOutWriterAdapter) {
try {
((XmlStreamOutWriterAdapter)out).writeEntityRef("#x" + Integer.toHexString(c));
} catch (XMLStreamException e) {
throw new IOException("Error writing xml stream", e);
}
} else {
out.write("&#x");
out.write(Integer.toHexString(c));
out.write(';');
}
}
}
if (lastEscaped != limit) { //here if char[] ch lenght is 0, then there's no way to run into the out.write
out.write(ch, lastEscaped, length - lastEscaped);
}
{code}
So if the text is empty then the underlying XMLStreamWriter.writeCharacters(...) will never be invoked, and hence what we do in JSONProviderTest$NullWriter will be skipped
[1]http://bugreport.java.com/
> Ensure CXF can build with JDK9 GA(build 9+181)
> ----------------------------------------------
>
> Key: CXF-7520
> URL: https://issues.apache.org/jira/browse/CXF-7520
> Project: CXF
> Issue Type: Bug
> Reporter: Freeman Fang
> Assignee: Freeman Fang
>
> a couple of cxf test failied with JDK9 GA due to recent change
> Mainly in JAXB and SAAJ
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)