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 2016/01/30 17:06:32 UTC
[8/8] camel git commit: CAMEL-9551: ErrorHandler - Should not log
message body by default.
CAMEL-9551: ErrorHandler - Should not log message body by default.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/9f66481e
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/9f66481e
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/9f66481e
Branch: refs/heads/master
Commit: 9f66481e0e399f89104141f271478adb0e813063
Parents: 1ac1336
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Jan 30 16:31:05 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Jan 30 17:06:16 2016 +0100
----------------------------------------------------------------------
.../apache/camel/processor/RedeliveryErrorHandler.java | 11 ++++++++---
.../DefaultErrorHandlerExchangeFormatterRefTest.java | 4 ----
2 files changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/9f66481e/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java b/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
index 20026f6..8c9a838 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
@@ -77,6 +77,7 @@ public abstract class RedeliveryErrorHandler extends ErrorHandlerSupport impleme
protected boolean redeliveryEnabled;
protected volatile boolean preparingShutdown;
protected final ExchangeFormatter exchangeFormatter;
+ protected final boolean customExchangeFormatter;
protected final Processor onPrepare;
/**
@@ -226,10 +227,12 @@ public abstract class RedeliveryErrorHandler extends ErrorHandlerSupport impleme
ExchangeFormatter formatter = camelContext.getRegistry().lookupByNameAndType(redeliveryPolicy.getExchangeFormatterRef(), ExchangeFormatter.class);
if (formatter != null) {
this.exchangeFormatter = formatter;
+ this.customExchangeFormatter = true;
} else {
throw new IllegalArgumentException("Cannot find the exchangeFormatter by using reference id " + redeliveryPolicy.getExchangeFormatterRef());
}
} else {
+ this.customExchangeFormatter = false;
// setup exchange formatter to be used for message history dump
DefaultExchangeFormatter formatter = new DefaultExchangeFormatter();
formatter.setShowExchangeId(true);
@@ -1140,7 +1143,9 @@ public abstract class RedeliveryErrorHandler extends ErrorHandlerSupport impleme
// should we include message history
if (!shouldRedeliver && data.currentRedeliveryPolicy.isLogExhaustedMessageHistory()) {
- String routeStackTrace = MessageHelper.dumpMessageHistoryStacktrace(exchange, exchangeFormatter, false);
+ // only use the exchange formatter if we should log exhausted message body (and if using a custom formatter then always use it)
+ ExchangeFormatter formatter = customExchangeFormatter ? exchangeFormatter : (data.currentRedeliveryPolicy.isLogExhaustedMessageBody() ? exchangeFormatter : null);
+ String routeStackTrace = MessageHelper.dumpMessageHistoryStacktrace(exchange, formatter, false);
if (routeStackTrace != null) {
msg = msg + "\n" + routeStackTrace;
}
@@ -1157,8 +1162,8 @@ public abstract class RedeliveryErrorHandler extends ErrorHandlerSupport impleme
String msg = message;
// should we include message history
if (!shouldRedeliver && data.currentRedeliveryPolicy.isLogExhaustedMessageHistory()) {
- // only use the exchange formatter if we should log exhausted message body
- ExchangeFormatter formatter = data.currentRedeliveryPolicy.isLogExhaustedMessageBody() ? exchangeFormatter : null;
+ // only use the exchange formatter if we should log exhausted message body (and if using a custom formatter then always use it)
+ ExchangeFormatter formatter = customExchangeFormatter ? exchangeFormatter : (data.currentRedeliveryPolicy.isLogExhaustedMessageBody() ? exchangeFormatter : null);
String routeStackTrace = MessageHelper.dumpMessageHistoryStacktrace(exchange, formatter, e != null && logStackTrace);
if (routeStackTrace != null) {
msg = msg + "\n" + routeStackTrace;
http://git-wip-us.apache.org/repos/asf/camel/blob/9f66481e/camel-core/src/test/java/org/apache/camel/processor/onexception/DefaultErrorHandlerExchangeFormatterRefTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/onexception/DefaultErrorHandlerExchangeFormatterRefTest.java b/camel-core/src/test/java/org/apache/camel/processor/onexception/DefaultErrorHandlerExchangeFormatterRefTest.java
index 26074bf..7f8650b 100644
--- a/camel-core/src/test/java/org/apache/camel/processor/onexception/DefaultErrorHandlerExchangeFormatterRefTest.java
+++ b/camel-core/src/test/java/org/apache/camel/processor/onexception/DefaultErrorHandlerExchangeFormatterRefTest.java
@@ -23,7 +23,6 @@ import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.JndiRegistry;
import org.apache.camel.spi.ExchangeFormatter;
-
public class DefaultErrorHandlerExchangeFormatterRefTest extends ContextTestSupport {
private static int invoked;
@@ -50,7 +49,6 @@ public class DefaultErrorHandlerExchangeFormatterRefTest extends ContextTestSupp
return new RouteBuilder() {
@Override
public void configure() throws Exception {
-
errorHandler(defaultErrorHandler().exchangeFormatterRef("myExchangeFormatter"));
from("direct:start").process(new MyProcessor());
@@ -61,9 +59,7 @@ public class DefaultErrorHandlerExchangeFormatterRefTest extends ContextTestSupp
public static class MyProcessor implements Processor {
public void process(Exchange exchange) throws Exception {
-
throw new MyFunctionalException("Sorry you cannot do this");
-
}
}