camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1415131 - in /camel/branches/camel-2.9.x: ./ camel-core/src/main/java/org/apache/camel/component/log/LogFormatter.java camel-core/src/test/java/org/apache/camel/component/log/LogFormatterTest.java
Date Thu, 29 Nov 2012 11:33:12 GMT
Author: davsclaus
Date: Thu Nov 29 11:33:11 2012
New Revision: 1415131

URL: http://svn.apache.org/viewvc?rev=1415131&view=rev
Log:
CAMEL-5699: Fixed NPE if all options disable on log formatter.

Modified:
    camel/branches/camel-2.9.x/   (props changed)
    camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/log/LogFormatter.java
    camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/component/log/LogFormatterTest.java

Propchange: camel/branches/camel-2.9.x/
------------------------------------------------------------------------------
  Merged /camel/trunk:r1415129
  Merged /camel/branches/camel-2.10.x:r1415130

Propchange: camel/branches/camel-2.9.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/log/LogFormatter.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/log/LogFormatter.java?rev=1415131&r1=1415130&r2=1415131&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/log/LogFormatter.java
(original)
+++ camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/component/log/LogFormatter.java
Thu Nov 29 11:33:11 2012
@@ -167,12 +167,24 @@ public class LogFormatter implements Exc
                 }
             }
 
-            // get rid of the leading space comma if needed
-            return "Exchange[" + (multiline ? answer.append(']').toString() : answer.toString().substring(2)
+ "]");
+            // switch string buffer
+            sb = answer;
         }
 
-        // get rid of the leading space comma if needed
-        return "Exchange[" + (multiline ? sb.append(']').toString() : sb.toString().substring(2)
+ "]");
+        if (multiline) {
+            sb.insert(0, "Exchange[");
+            sb.append("]");
+            return sb.toString();
+        } else {
+            // get rid of the leading space comma if needed
+            if (sb.length() > 0 && sb.charAt(0) == ',' && sb.charAt(1)
== ' ') {
+                sb.replace(0, 2, "");
+            }
+            sb.insert(0, "Exchange[");
+            sb.append("]");
+
+            return sb.toString();
+        }
     }
 
     public boolean isShowExchangeId() {

Modified: camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/component/log/LogFormatterTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/component/log/LogFormatterTest.java?rev=1415131&r1=1415130&r2=1415131&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/component/log/LogFormatterTest.java
(original)
+++ camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/component/log/LogFormatterTest.java
Thu Nov 29 11:33:11 2012
@@ -34,6 +34,10 @@ public class LogFormatterTest extends Co
         template.sendBody("log:org.apache.camel.TEST", "Hello World");
     }
 
+    public void testSendMessageToLogAllOff() throws Exception {
+        template.sendBody("log:org.apache.camel.TEST?showBody=false&showBodyType=false&showExchangePattern=false",
"Hello World");
+    }
+
     public void testSendMessageToLogSingleOptions() throws Exception {
         template.sendBody("log:org.apache.camel.TEST?showExchangeId=true", "Hello World");
         template.sendBody("log:org.apache.camel.TEST?showExchangePattern=true", "Hello World");



Mime
View raw message