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 2014/09/11 19:01:42 UTC
git commit: CAMEL-7804: MessageHelper - dump message for logging
should catch throwable
Repository: camel
Updated Branches:
refs/heads/master 43161eff5 -> 4b0408e74
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/4b0408e7
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/4b0408e7
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/4b0408e7
Branch: refs/heads/master
Commit: 4b0408e748b01cb7f84517618c784a11bda10565
Parents: 43161ef
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Sep 11 18:59:44 2014 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Sep 11 18:59:52 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/4b0408e7/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 502da6a..879fcbf 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
@@ -301,13 +301,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
@@ -409,13 +413,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
}
}
@@ -483,7 +487,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 "";
}
}
@@ -522,7 +527,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();