cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject git commit: Allow -1 for the limit
Date Tue, 01 Jul 2014 17:49:48 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 34c814b64 -> d40ea830b


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

Branch: refs/heads/master
Commit: d40ea830bd7ddd973d9b2b15b42783f30a399790
Parents: 34c814b
Author: Daniel Kulp <dkulp@apache.org>
Authored: Tue Jul 1 13:49:34 2014 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Tue Jul 1 13:49:34 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/d40ea830/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java b/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
index 5df0e8e..c2510c5 100644
--- a/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
+++ b/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
@@ -172,7 +172,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);
@@ -194,7 +194,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);
             
@@ -210,7 +210,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/d40ea830/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java b/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java
index 2b82cdc..a037c4e 100644
--- a/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java
+++ b/core/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 {


Mime
View raw message