From ec6db10c7e833690600634fa04d3c7d995317aba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Baptiste=20Onofr=C3=A9?= Date: Thu, 23 Dec 2021 07:26:19 +0100 Subject: [PATCH] [AMQ-8252] Introduce stackTraceEnabled flag on transport connector to define if the stack trace should be displayed or not in case of WARN messages (cherry picked from commit 2f96b4a60c30f1d9a3ce047aa41a94d975324d83) --- .../apache/activemq/broker/TransportConnection.java | 13 ++++++------- .../apache/activemq/broker/TransportConnector.java | 9 +++++++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/TransportConnection.java b/activemq-broker/src/main/java/org/apache/activemq/broker/TransportConnection.java index 44b7968113..ac827b8f72 100644 --- a/activemq-broker/src/main/java/org/apache/activemq/broker/TransportConnection.java +++ b/activemq-broker/src/main/java/org/apache/activemq/broker/TransportConnection.java @@ -240,19 +240,18 @@ public class TransportConnection implements Connection, Task, CommandVisitor { if (TRANSPORTLOG.isDebugEnabled()) { TRANSPORTLOG.debug("{} failed: {}", this, e.getMessage(), e); } else if (TRANSPORTLOG.isWarnEnabled() && !suppressed(e)) { - TRANSPORTLOG.warn("{} failed", this, e); + if (connector.isDisplayStackTrace()) { + TRANSPORTLOG.warn("{} failed", this, e); + } else { + TRANSPORTLOG.warn("{} failed: {}", this, e.getMessage()); + } } stopAsync(e); } } private boolean suppressed(IOException e) { - return (isStomp() || !connector.isWarnOnRemoteClose()) && ((e instanceof SocketException && e.getMessage().indexOf("reset") != -1) || e instanceof EOFException); - } - - private boolean isStomp() { - URI uri = connector.getUri(); - return uri != null && uri.getScheme() != null && uri.getScheme().indexOf("stomp") != -1; + return (!connector.isWarnOnRemoteClose()) && ((e instanceof SocketException && e.getMessage().indexOf("reset") != -1) || e instanceof EOFException); } /** diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/TransportConnector.java b/activemq-broker/src/main/java/org/apache/activemq/broker/TransportConnector.java index 3358eeea15..1b9c41fa4b 100644 --- a/activemq-broker/src/main/java/org/apache/activemq/broker/TransportConnector.java +++ b/activemq-broker/src/main/java/org/apache/activemq/broker/TransportConnector.java @@ -78,6 +78,7 @@ public class TransportConnector implements Connector, BrokerServiceAware { private PublishedAddressPolicy publishedAddressPolicy = new PublishedAddressPolicy(); private boolean allowLinkStealing = false; private boolean warnOnRemoteClose = false; + private boolean displayStackTrace = false; LinkedList peerBrokers = new LinkedList(); @@ -664,4 +665,12 @@ public class TransportConnector implements Connector, BrokerServiceAware { public void setWarnOnRemoteClose(boolean warnOnRemoteClose) { this.warnOnRemoteClose = warnOnRemoteClose; } + + public boolean isDisplayStackTrace() { + return displayStackTrace; + } + + public void setDisplayStackTrace(boolean displayStackTrace) { + this.displayStackTrace = displayStackTrace; + } }