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/07/01 20:22:13 UTC
[1/3] git commit: [CXF-5829, CXF-5761] Backport CXF-5761 to 2.6.x
Repository: cxf
Updated Branches:
refs/heads/2.6.x-fixes 1ae35cfba -> 4347218d3
[CXF-5829, CXF-5761] Backport CXF-5761 to 2.6.x
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/aaa6de9c
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/aaa6de9c
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/aaa6de9c
Branch: refs/heads/2.6.x-fixes
Commit: aaa6de9cef123a06946c575f87c0c11948d54ab0
Parents: 1ae35cf
Author: Daniel Kulp <dk...@apache.org>
Authored: Tue Jul 1 13:11:20 2014 -0400
Committer: Daniel Kulp <dk...@apache.org>
Committed: Tue Jul 1 14:20:27 2014 -0400
----------------------------------------------------------------------
.../interceptor/AbstractLoggingInterceptor.java | 43 ++++++++++++--------
1 file changed, 27 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/aaa6de9c/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..77b674b 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,20 +31,20 @@ 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
@@ -155,13 +156,24 @@ 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());
@@ -187,14 +199,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/3] git commit: Allow -1 for the limit
Posted by dk...@apache.org.
Allow -1 for the limit
Conflicts:
api/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/6c30be62
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/6c30be62
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/6c30be62
Branch: refs/heads/2.6.x-fixes
Commit: 6c30be6277eed5712040d21c01d80ed14b167ff8
Parents: aaa6de9
Author: Daniel Kulp <dk...@apache.org>
Authored: Tue Jul 1 13:49:34 2014 -0400
Committer: Daniel Kulp <dk...@apache.org>
Committed: Tue Jul 1 14:22:05 2014 -0400
----------------------------------------------------------------------
.../cxf/interceptor/LoggingInInterceptor.java | 4 ++--
.../cxf/interceptor/LoggingOutInterceptor.java | 22 ++++++++++++--------
2 files changed, 15 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/6c30be62/api/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java b/api/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
index a00dba9..5df82ed 100644
--- a/api/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
+++ b/api/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
@@ -170,7 +170,7 @@ public class LoggingInInterceptor extends AbstractLoggingInterceptor {
//only copy up to the limit since that's all we need to log
//we can stream the rest
- IOUtils.copyAtLeast(bis, bos, limit);
+ IOUtils.copyAtLeast(bis, bos, limit == -1 ? Integer.MAX_VALUE : limit);
bos.flush();
bis = new SequenceInputStream(bos.getInputStream(), bis);
@@ -186,7 +186,7 @@ public class LoggingInInterceptor extends AbstractLoggingInterceptor {
buffer.getMessage().append("\nMessage (saved to tmp file):\n");
buffer.getMessage().append("Filename: " + bos.getTempFile().getAbsolutePath() + "\n");
}
- if (bos.size() > limit) {
+ if (bos.size() > limit && limit != -1) {
buffer.getMessage().append("(message truncated to " + limit + " bytes)\n");
}
writePayload(buffer.getPayload(), bos, encoding, ct);
http://git-wip-us.apache.org/repos/asf/cxf/blob/6c30be62/api/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java b/api/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java
index bd7cab1..ed88d14 100644
--- a/api/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java
+++ b/api/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java
@@ -135,6 +135,7 @@ public class LoggingOutInterceptor extends AbstractLoggingInterceptor {
int count;
Logger logger; //NOPMD
Message message;
+ final int lim;
public LogWriter(Logger logger, Message message, Writer writer) {
super(writer);
@@ -143,32 +144,33 @@ public class LoggingOutInterceptor extends AbstractLoggingInterceptor {
if (!(writer instanceof StringWriter)) {
out2 = new StringWriter();
}
+ lim = limit == -1 ? Integer.MAX_VALUE : limit;
}
public void write(int c) throws IOException {
super.write(c);
- if (out2 != null && count < limit) {
+ if (out2 != null && count < lim) {
out2.write(c);
}
count++;
}
public void write(char[] cbuf, int off, int len) throws IOException {
super.write(cbuf, off, len);
- if (out2 != null && count < limit) {
+ if (out2 != null && count < lim) {
out2.write(cbuf, off, len);
}
count += len;
}
public void write(String str, int off, int len) throws IOException {
super.write(str, off, len);
- if (out2 != null && count < limit) {
+ if (out2 != null && count < lim) {
out2.write(str, off, len);
}
count += len;
}
public void close() throws IOException {
LoggingMessage buffer = setupBuffer(message);
- if (count >= limit) {
- buffer.getMessage().append("(message truncated to " + limit + " bytes)\n");
+ if (count >= lim) {
+ buffer.getMessage().append("(message truncated to " + lim + " bytes)\n");
}
StringWriter w2 = out2;
if (w2 == null) {
@@ -195,11 +197,13 @@ public class LoggingOutInterceptor extends AbstractLoggingInterceptor {
private final Message message;
private final OutputStream origStream;
private final Logger logger; //NOPMD
+ private final int lim;
public LoggingCallback(final Logger logger, final Message msg, final OutputStream os) {
this.logger = logger;
this.message = msg;
this.origStream = os;
+ this.lim = limit == -1 ? Integer.MAX_VALUE : limit;
}
public void onFlush(CachedOutputStream cos) {
@@ -218,14 +222,14 @@ public class LoggingOutInterceptor extends AbstractLoggingInterceptor {
if (cos.getTempFile() == null) {
//buffer.append("Outbound Message:\n");
- if (cos.size() >= limit) {
- buffer.getMessage().append("(message truncated to " + limit + " bytes)\n");
+ if (cos.size() >= lim) {
+ buffer.getMessage().append("(message truncated to " + lim + " bytes)\n");
}
} else {
buffer.getMessage().append("Outbound Message (saved to tmp file):\n");
buffer.getMessage().append("Filename: " + cos.getTempFile().getAbsolutePath() + "\n");
- if (cos.size() >= limit) {
- buffer.getMessage().append("(message truncated to " + limit + " bytes)\n");
+ if (cos.size() >= lim) {
+ buffer.getMessage().append("(message truncated to " + lim + " bytes)\n");
}
}
try {
[3/3] 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/4347218d
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/4347218d
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/4347218d
Branch: refs/heads/2.6.x-fixes
Commit: 4347218d37056784095a255cd05d3d41389a74d3
Parents: 6c30be6
Author: Daniel Kulp <dk...@apache.org>
Authored: Tue Jul 1 14:22:05 2014 -0400
Committer: Daniel Kulp <dk...@apache.org>
Committed: Tue Jul 1 14:22:05 2014 -0400
----------------------------------------------------------------------
.gitmergeinfo | 2 ++
1 file changed, 2 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/4347218d/.gitmergeinfo
----------------------------------------------------------------------
diff --git a/.gitmergeinfo b/.gitmergeinfo
index f90ee47..4157e73 100644
--- a/.gitmergeinfo
+++ b/.gitmergeinfo
@@ -187,6 +187,7 @@ B 2a25cd21f1c339c3f5e546986104e5dc2261f60b
B 2a548e8c23ac00d2698e93aa1b7435439b329b0e
B 2a743ebbd824eb4c84fe7dc747851097628bd472
B 2a8f8f5ba4e57c6c487d59b7121689c60d7fa091
+B 2b74eea72a3c163edc9614cd7db7c83c5884a4d0
B 2be20f00d61bdab039af20ae2e8fec66774f8425
B 2be3af700bcd3b956297dfe925546faccb60ef0b
B 2c1b1627a412eadd72d51e2058a34a7a4a86f8e4
@@ -1438,6 +1439,7 @@ M a5f5fadd29ddb3fea6d0e6f1e0e55b2a448d7e7e
M a601626ba8afa149b1d8c49ea10288f85fd65cda
M a60482596fd1bd7f1f034e12913dfb66de6d4dda
M a60efafbabdbb4b7ac35337f2c1729dc749671e0
+M a6d699868f6d66f2795852a38662acff2870d20e
M a6e0d8a6794a3747acc57603f4112aed713e2b4a
M a7ed433e50e8c28fb12e6bf45505aaff78daac1c
M a95114e138410835fe8c8c7d979a5a945425f3fd