cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-7033] Using the emcoding property when creating a pretty-printed payload, patch from Daniel Baumann applied, This closes #163
Date Fri, 09 Sep 2016 16:17:25 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes d54393bc1 -> 1b1740022


[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/1b174002
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/1b174002
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/1b174002

Branch: refs/heads/3.0.x-fixes
Commit: 1b174002280f44a024898e835fe729ead86bd8ac
Parents: d54393b
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Fri Sep 9 17:15:27 2016 +0100
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Fri Sep 9 17:17:11 2016 +0100

----------------------------------------------------------------------
 .../cxf/interceptor/AbstractLoggingInterceptor.java    | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/1b174002/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 a7b2fa6..5174e71 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;
@@ -157,15 +158,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 {
@@ -180,9 +181,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 {
@@ -199,7 +200,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);


Mime
View raw message