You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2013/06/19 17:24:17 UTC

git commit: CAMEL-6407: Fixed message history dump must not throw exception

Updated Branches:
  refs/heads/master bab6461cb -> 4f840ca47


CAMEL-6407: Fixed message history dump must not throw exception


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

Branch: refs/heads/master
Commit: 4f840ca472efbf58e2e5d4b39890cb9b6b315dd9
Parents: bab6461
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Jun 19 17:23:55 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Jun 19 17:23:55 2013 +0200

----------------------------------------------------------------------
 .../java/org/apache/camel/util/MessageHelper.java   | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/4f840ca4/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 f732645..b8a984c 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
@@ -406,8 +406,17 @@ public final class MessageHelper {
      * @param logStackTrace      whether to include a header for the stacktrace, to be added (not included in this dump).
      * @return a human readable message history as a table
      */
-    @SuppressWarnings("unchecked")
     public static String dumpMessageHistoryStacktrace(Exchange exchange, ExchangeFormatter exchangeFormatter, boolean logStackTrace) {
+        // must not cause new exceptions so run this in a try catch block
+        try {
+            return doDumpMessageHistoryStacktrace(exchange, exchangeFormatter, logStackTrace);
+        } catch (Exception e) {
+            return "";
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    public static String doDumpMessageHistoryStacktrace(Exchange exchange, ExchangeFormatter exchangeFormatter, boolean logStackTrace) {
         List<MessageHistory> list = exchange.getProperty(Exchange.MESSAGE_HISTORY, List.class);
         if (list == null || list.isEmpty()) {
             return null;
@@ -423,7 +432,10 @@ public final class MessageHelper {
         // add incoming origin of message on the top
         String routeId = exchange.getFromRouteId();
         String id = routeId;
-        String label = URISupport.sanitizeUri(exchange.getFromEndpoint().getEndpointUri());
+        String label = "";
+        if (exchange.getFromEndpoint() != null) {
+            label = URISupport.sanitizeUri(exchange.getFromEndpoint().getEndpointUri());
+        }
         long elapsed = 0;
         Date created = exchange.getProperty(Exchange.CREATED_TIMESTAMP, Date.class);
         if (created != null) {