Mon, 23 Apr 2018 13:24:44 +0100
8196491: Newlines in JAXB string values of SOAP-requests are escaped to "
"
Reviewed-by: lancea, rgrigoriadi
1.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/output/XMLStreamWriterOutput.java Tue Apr 03 17:09:13 2018 -0700 1.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/output/XMLStreamWriterOutput.java Mon Apr 23 13:24:44 2018 +0100 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -33,6 +33,7 @@ 1.11 import javax.xml.stream.XMLStreamWriter; 1.12 1.13 import com.sun.xml.internal.bind.marshaller.CharacterEscapeHandler; 1.14 +import com.sun.xml.internal.bind.marshaller.NoEscapeHandler; 1.15 import com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl; 1.16 import com.sun.xml.internal.bind.v2.runtime.XMLSerializer; 1.17 1.18 @@ -71,7 +72,7 @@ 1.19 } 1.20 1.21 CharacterEscapeHandler xmlStreamEscapeHandler = escapeHandler != null ? 1.22 - escapeHandler : NewLineEscapeHandler.theInstance; 1.23 + escapeHandler : NoEscapeHandler.theInstance; 1.24 1.25 // otherwise the normal writer. 1.26 return new XMLStreamWriterOutput(out, xmlStreamEscapeHandler); 1.27 @@ -217,45 +218,6 @@ 1.28 } 1.29 } 1.30 1.31 - 1.32 - /** 1.33 - * Performs character escaping only for new lines. 1.34 - */ 1.35 - private static class NewLineEscapeHandler implements CharacterEscapeHandler { 1.36 - 1.37 - public static final NewLineEscapeHandler theInstance = new NewLineEscapeHandler(); 1.38 - 1.39 - @Override 1.40 - public void escape(char[] ch, int start, int length, boolean isAttVal, Writer out) throws IOException { 1.41 - int limit = start+length; 1.42 - int lastEscaped = start; 1.43 - 1.44 - for (int i = start; i < limit; i++) { 1.45 - char c = ch[i]; 1.46 - if (c == '\r' || c == '\n') { 1.47 - if (i != lastEscaped) { 1.48 - out.write(ch, lastEscaped, i - lastEscaped); 1.49 - } 1.50 - lastEscaped = i + 1; 1.51 - if (out instanceof XmlStreamOutWriterAdapter) { 1.52 - try { 1.53 - ((XmlStreamOutWriterAdapter)out).writeEntityRef("#x" + Integer.toHexString(c)); 1.54 - } catch (XMLStreamException e) { 1.55 - throw new IOException("Error writing xml stream", e); 1.56 - } 1.57 - } else { 1.58 - out.write("&#x"); 1.59 - out.write(Integer.toHexString(c)); 1.60 - out.write(';'); 1.61 - } 1.62 - } 1.63 - } 1.64 - if (lastEscaped != limit) { 1.65 - out.write(ch, lastEscaped, length - lastEscaped); 1.66 - } 1.67 - } 1.68 - } 1.69 - 1.70 private static final class XmlStreamOutWriterAdapter extends Writer { 1.71 1.72 private final XMLStreamWriter writer;
2.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamWriterFactory.java Tue Apr 03 17:09:13 2018 -0700 2.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamWriterFactory.java Mon Apr 23 13:24:44 2018 +0100 2.3 @@ -1,5 +1,5 @@ 2.4 /* 2.5 - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. 2.6 + * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. 2.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.8 * 2.9 * This code is free software; you can redistribute it and/or modify it 2.10 @@ -386,7 +386,7 @@ 2.11 2.12 } 2.13 2.14 - private static class HasEncodingWriter extends XMLStreamWriterFilter implements HasEncoding { 2.15 + public static class HasEncodingWriter extends XMLStreamWriterFilter implements HasEncoding { 2.16 private final String encoding; 2.17 2.18 HasEncodingWriter(XMLStreamWriter writer, String encoding) { 2.19 @@ -399,7 +399,7 @@ 2.20 return encoding; 2.21 } 2.22 2.23 - XMLStreamWriter getWriter() { 2.24 + public XMLStreamWriter getWriter() { 2.25 return writer; 2.26 } 2.27 }
3.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/ws/streaming/XMLStreamWriterUtil.java Tue Apr 03 17:09:13 2018 -0700 3.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/streaming/XMLStreamWriterUtil.java Mon Apr 23 13:24:44 2018 +0100 3.3 @@ -1,5 +1,5 @@ 3.4 /* 3.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 3.6 + * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. 3.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.8 * 3.9 * This code is free software; you can redistribute it and/or modify it 3.10 @@ -26,6 +26,7 @@ 3.11 package com.sun.xml.internal.ws.streaming; 3.12 3.13 import com.sun.istack.internal.Nullable; 3.14 +import com.sun.xml.internal.ws.api.streaming.XMLStreamWriterFactory; 3.15 import com.sun.xml.internal.ws.encoding.HasEncoding; 3.16 import com.sun.xml.internal.ws.encoding.SOAPBindingCodec; 3.17 3.18 @@ -57,9 +58,15 @@ 3.19 public static @Nullable OutputStream getOutputStream(XMLStreamWriter writer) throws XMLStreamException { 3.20 Object obj = null; 3.21 3.22 + XMLStreamWriter xmlStreamWriter = 3.23 + writer instanceof XMLStreamWriterFactory.HasEncodingWriter ? 3.24 + ((XMLStreamWriterFactory.HasEncodingWriter) writer).getWriter() 3.25 + : writer; 3.26 + 3.27 + 3.28 // Hack for JDK6's SJSXP 3.29 - if (writer instanceof Map) { 3.30 - obj = ((Map) writer).get("sjsxp-outputstream"); 3.31 + if (xmlStreamWriter instanceof Map) { 3.32 + obj = ((Map) xmlStreamWriter).get("sjsxp-outputstream"); 3.33 } 3.34 3.35 // woodstox