camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [2/2] git commit: CAMEL-7804: MessageHelper - dump message for logging should catch throwable
Date Fri, 12 Sep 2014 05:28:15 GMT
CAMEL-7804: MessageHelper - dump message for logging should catch throwable


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/909788c8
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/909788c8
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/909788c8

Branch: refs/heads/camel-2.12.x
Commit: 909788c8eaf577a5414c25b5a0094ed1de2cb394
Parents: 767cca8
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Thu Sep 11 18:59:44 2014 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Fri Sep 12 07:28:02 2014 +0200

----------------------------------------------------------------------
 .../org/apache/camel/util/MessageHelper.java     | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/909788c8/camel-core/src/main/java/org/apache/camel/util/MessageHelper.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/MessageHelper.java b/camel-core/src/main/java/org/apache/camel/util/MessageHelper.java
index 0182594..ec088f3 100644
--- a/camel-core/src/main/java/org/apache/camel/util/MessageHelper.java
+++ b/camel-core/src/main/java/org/apache/camel/util/MessageHelper.java
@@ -251,13 +251,17 @@ public final class MessageHelper {
         String body = null;
         if (message.getExchange() != null) {
             try {
-                body = message.getExchange().getContext().getTypeConverter().convertTo(String.class,
message.getExchange(), obj);
-            } catch (Exception e) {
+                body = message.getExchange().getContext().getTypeConverter().tryConvertTo(String.class,
message.getExchange(), obj);
+            } catch (Throwable e) {
                 // ignore as the body is for logging purpose
             }
         }
         if (body == null) {
-            body = obj.toString();
+            try {
+                body = obj.toString();
+            } catch (Throwable e) {
+                // ignore as the body is for logging purpose
+            }
         }
 
         // reset stream cache after use
@@ -359,13 +363,13 @@ public final class MessageHelper {
                 // to String
                 if (value != null) {
                     try {
-                        String xml = message.getExchange().getContext().getTypeConverter().convertTo(String.class,

+                        String xml = message.getExchange().getContext().getTypeConverter().tryConvertTo(String.class,
                                 message.getExchange(), value);
                         if (xml != null) {
                             // must always xml encode
                             sb.append(StringHelper.xmlEncode(xml));
                         }
-                    } catch (Exception e) {
+                    } catch (Throwable e) {
                         // ignore as the body is for logging purpose
                     }
                 }
@@ -433,7 +437,8 @@ public final class MessageHelper {
         // must not cause new exceptions so run this in a try catch block
         try {
             return doDumpMessageHistoryStacktrace(exchange, exchangeFormatter, logStackTrace);
-        } catch (Exception e) {
+        } catch (Throwable e) {
+            // ignore as the body is for logging purpose
             return "";
         }
     }
@@ -472,7 +477,7 @@ public final class MessageHelper {
         for (MessageHistory history : list) {
             routeId = history.getRouteId() != null ? history.getRouteId() : "";
             id = history.getNode().getId();
-            // we need to avoid leak the sensibale information here
+            // we need to avoid leak the sensible information here
             label =  URISupport.sanitizeUri(history.getNode().getLabel());
             elapsed = history.getElapsed();
 


Mime
View raw message