You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2014/06/12 17:03:47 UTC
[1/2] git commit: [CXF-5761] When pretty writing,
ignore any errors as they could be caused by the truncation
Repository: cxf
Updated Branches:
refs/heads/2.7.x-fixes b9d8aee62 -> 41e11d892
[CXF-5761] When pretty writing, ignore any errors as they could be caused by the truncation
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/88c98e8a
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/88c98e8a
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/88c98e8a
Branch: refs/heads/2.7.x-fixes
Commit: 88c98e8a3e300040007bc6552a2986b142204347
Parents: b9d8aee
Author: Daniel Kulp <dk...@apache.org>
Authored: Thu Jun 12 10:53:42 2014 -0400
Committer: Daniel Kulp <dk...@apache.org>
Committed: Thu Jun 12 11:03:14 2014 -0400
----------------------------------------------------------------------
.../interceptor/AbstractLoggingInterceptor.java | 44 ++++++++++++--------
1 file changed, 27 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/88c98e8a/api/src/main/java/org/apache/cxf/interceptor/AbstractLoggingInterceptor.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/cxf/interceptor/AbstractLoggingInterceptor.java b/api/src/main/java/org/apache/cxf/interceptor/AbstractLoggingInterceptor.java
index 8ba74dd..d724f5b 100644
--- a/api/src/main/java/org/apache/cxf/interceptor/AbstractLoggingInterceptor.java
+++ b/api/src/main/java/org/apache/cxf/interceptor/AbstractLoggingInterceptor.java
@@ -20,6 +20,7 @@ package org.apache.cxf.interceptor;
import java.io.File;
import java.io.FileWriter;
+import java.io.InputStream;
import java.io.PrintWriter;
import java.io.StringReader;
import java.io.StringWriter;
@@ -30,27 +31,26 @@ import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.stream.StreamResult;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
import javax.xml.transform.stream.StreamSource;
import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.endpoint.Endpoint;
-import org.apache.cxf.helpers.XMLUtils;
import org.apache.cxf.io.CachedOutputStream;
import org.apache.cxf.message.Message;
import org.apache.cxf.phase.AbstractPhaseInterceptor;
import org.apache.cxf.service.model.EndpointInfo;
import org.apache.cxf.service.model.InterfaceInfo;
+import org.apache.cxf.staxutils.PrettyPrintXMLStreamWriter;
+import org.apache.cxf.staxutils.StaxUtils;
/**
* A simple logging handler which outputs the bytes of the message to the
* Logger.
*/
public abstract class AbstractLoggingInterceptor extends AbstractPhaseInterceptor<Message> {
-
protected static final String BINARY_CONTENT_MESSAGE = "--- Binary Content ---";
private static final List<String> BINARY_CONTENT_MEDIA_TYPES;
static {
@@ -155,13 +155,25 @@ public abstract class AbstractLoggingInterceptor extends AbstractPhaseIntercepto
// 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) {
- Transformer serializer = XMLUtils.newTransformer(2);
- // Setup indenting to "pretty print"
- serializer.setOutputProperty(OutputKeys.INDENT, "yes");
- serializer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
StringWriter swriter = new StringWriter();
- serializer.transform(new StreamSource(cos.getInputStream()), new StreamResult(swriter));
+ XMLStreamWriter xwriter = StaxUtils.createXMLStreamWriter(swriter);
+ xwriter = new PrettyPrintXMLStreamWriter(xwriter, 2);
+ InputStream in = cos.getInputStream();
+ try {
+ StaxUtils.copy(new StreamSource(in), xwriter);
+ } catch (XMLStreamException xse) {
+ //ignore
+ } finally {
+ try {
+ xwriter.flush();
+ xwriter.close();
+ } catch (XMLStreamException xse2) {
+ //ignore
+ }
+ in.close();
+ }
+
String result = swriter.toString();
if (result.length() < limit || limit == -1) {
builder.append(swriter.toString());
@@ -175,7 +187,6 @@ public abstract class AbstractLoggingInterceptor extends AbstractPhaseIntercepto
} else {
cos.writeCacheTo(builder, encoding, limit);
}
-
}
}
protected void writePayload(StringBuilder builder,
@@ -187,14 +198,13 @@ public abstract class AbstractLoggingInterceptor extends AbstractPhaseIntercepto
&& contentType != null
&& contentType.indexOf("xml") >= 0
&& stringWriter.getBuffer().length() > 0) {
- Transformer serializer = XMLUtils.newTransformer(2);
- // Setup indenting to "pretty print"
- serializer.setOutputProperty(OutputKeys.INDENT, "yes");
- serializer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
StringWriter swriter = new StringWriter();
- serializer.transform(new StreamSource(new StringReader(stringWriter.getBuffer().toString())),
- new StreamResult(swriter));
+ XMLStreamWriter xwriter = StaxUtils.createXMLStreamWriter(swriter);
+ xwriter = new PrettyPrintXMLStreamWriter(xwriter, 2);
+ StaxUtils.copy(new StreamSource(new StringReader(stringWriter.getBuffer().toString())), xwriter);
+ xwriter.close();
+
String result = swriter.toString();
if (result.length() < limit || limit == -1) {
builder.append(swriter.toString());
[2/2] git commit: Recording .gitmergeinfo Changes
Posted by dk...@apache.org.
Recording .gitmergeinfo Changes
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/41e11d89
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/41e11d89
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/41e11d89
Branch: refs/heads/2.7.x-fixes
Commit: 41e11d892c3976d64a146b6a5489f5a303839d6f
Parents: 88c98e8
Author: Daniel Kulp <dk...@apache.org>
Authored: Thu Jun 12 11:03:40 2014 -0400
Committer: Daniel Kulp <dk...@apache.org>
Committed: Thu Jun 12 11:03:40 2014 -0400
----------------------------------------------------------------------
.gitmergeinfo | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/41e11d89/.gitmergeinfo
----------------------------------------------------------------------
diff --git a/.gitmergeinfo b/.gitmergeinfo
index 8a3a1b8..9030aaa 100644
--- a/.gitmergeinfo
+++ b/.gitmergeinfo
@@ -1349,6 +1349,7 @@ M 5e1a629f038e38baa59ccf04e4203dde23548d73
M 5e63a91cb80e3aec8eaafb300ca607305c592827
M 5e7356aecc3e0d9e3853c3b800b9690e84b34e0a
M 5e832944780870f3bf0539b1ee40f62fec493807
+M 5ec1b6025d1fd35157b7ce862198c61a7810e499
M 5f9152b79faa7a49a1d82c864e7306dacba4321f
M 6019486954e7e48efbd393f5fe1e7dcee3a2253c
M 608b823b5eb576cca77e92ac6298ef63c6d65c99