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:20:20 UTC
[2/2] git commit: Allow -1 for the limit
Allow -1 for the limit
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/a6d69986
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/a6d69986
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/a6d69986
Branch: refs/heads/2.7.x-fixes
Commit: a6d699868f6d66f2795852a38662acff2870d20e
Parents: c296f50
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:20:09 2014 -0400
----------------------------------------------------------------------
.../cxf/interceptor/LoggingInInterceptor.java | 6 +++---
.../cxf/interceptor/LoggingOutInterceptor.java | 22 ++++++++++++--------
2 files changed, 16 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/a6d69986/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 c2ed46d..bf4f531 100644
--- a/api/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
+++ b/api/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
@@ -171,7 +171,7 @@ public class LoggingInInterceptor extends AbstractLoggingInterceptor {
buffer.getMessage().append("\nMessage (saved to tmp file):\n");
buffer.getMessage().append("Filename: " + writer.getTempFile().getAbsolutePath() + "\n");
}
- if (writer.size() > limit) {
+ if (writer.size() > limit && limit != -1) {
buffer.getMessage().append("(message truncated to " + limit + " bytes)\n");
}
writer.writeCacheTo(buffer.getPayload(), limit);
@@ -193,7 +193,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);
@@ -209,7 +209,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/a6d69986/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 2b82cdc..a037c4e 100644
--- a/api/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java
+++ b/api/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java
@@ -142,6 +142,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);
@@ -150,32 +151,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) {
@@ -202,11 +204,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) {
@@ -225,14 +229,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 {