You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2016/09/09 16:15:41 UTC
cxf git commit: [CXF-7033] Using the emcoding property when creating
a pretty-printed payload, patch from Daniel Baumann applied, This closes #163
Repository: cxf
Updated Branches:
refs/heads/master d5373a3e3 -> 9e413483e
[CXF-7033] Using the emcoding property when creating a pretty-printed payload, patch from Daniel Baumann applied, This closes #163
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/9e413483
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/9e413483
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/9e413483
Branch: refs/heads/master
Commit: 9e413483e41d50229e57a052ea0090e74724a1f1
Parents: d5373a3
Author: Sergey Beryozkin <sb...@gmail.com>
Authored: Fri Sep 9 17:15:27 2016 +0100
Committer: Sergey Beryozkin <sb...@gmail.com>
Committed: Fri Sep 9 17:15:27 2016 +0100
----------------------------------------------------------------------
.../cxf/interceptor/AbstractLoggingInterceptor.java | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/9e413483/core/src/main/java/org/apache/cxf/interceptor/AbstractLoggingInterceptor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/interceptor/AbstractLoggingInterceptor.java b/core/src/main/java/org/apache/cxf/interceptor/AbstractLoggingInterceptor.java
index ae994c4..889f4f6 100644
--- a/core/src/main/java/org/apache/cxf/interceptor/AbstractLoggingInterceptor.java
+++ b/core/src/main/java/org/apache/cxf/interceptor/AbstractLoggingInterceptor.java
@@ -21,6 +21,7 @@ package org.apache.cxf.interceptor;
import java.io.File;
import java.io.FileWriter;
import java.io.InputStream;
+import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringReader;
import java.io.StringWriter;
@@ -167,15 +168,15 @@ public abstract class AbstractLoggingInterceptor extends AbstractPhaseIntercepto
String encoding, String contentType)
throws Exception {
// Just transform the XML message when the cos has content
- if (isPrettyLogging() && (contentType != null && contentType.indexOf("xml") >= 0
- && contentType.toLowerCase().indexOf("multipart/related") < 0) && cos.size() > 0) {
+ if (isPrettyLogging() && contentType != null && contentType.contains("xml")
+ && !contentType.toLowerCase().contains("multipart/related") && cos.size() > 0) {
StringWriter swriter = new StringWriter();
XMLStreamWriter xwriter = StaxUtils.createXMLStreamWriter(swriter);
xwriter = new PrettyPrintXMLStreamWriter(xwriter, 2);
InputStream in = cos.getInputStream();
try {
- StaxUtils.copy(new StreamSource(in), xwriter);
+ StaxUtils.copy(new StreamSource(new InputStreamReader(in, encoding)), xwriter);
} catch (XMLStreamException xse) {
//ignore
} finally {
@@ -190,9 +191,9 @@ public abstract class AbstractLoggingInterceptor extends AbstractPhaseIntercepto
String result = swriter.toString();
if (result.length() < limit || limit == -1) {
- builder.append(swriter.toString());
+ builder.append(result);
} else {
- builder.append(swriter.toString().substring(0, limit));
+ builder.append(result.substring(0, limit));
}
} else {
@@ -209,7 +210,7 @@ public abstract class AbstractLoggingInterceptor extends AbstractPhaseIntercepto
throws Exception {
if (isPrettyLogging()
&& contentType != null
- && contentType.indexOf("xml") >= 0
+ && contentType.contains("xml")
&& stringWriter.getBuffer().length() > 0) {
try {
writePrettyPayload(builder, stringWriter, contentType);