cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [2/3] git commit: Allow -1 for the limit
Date Tue, 01 Jul 2014 18:22:14 GMT
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 <dkulp@apache.org>
Authored: Tue Jul 1 13:49:34 2014 -0400
Committer: Daniel Kulp <dkulp@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 {


Mime
View raw message