[AMQ-8252] Introduce stackTraceEnabled flag on transport connector to define if the stack trace should be displayed or not in case of WARN messages

This commit is contained in:
Jean-Baptiste Onofré 2021-12-23 07:26:19 +01:00
parent ff134fd135
commit 2f96b4a60c
2 changed files with 15 additions and 7 deletions

View File

@ -240,19 +240,18 @@ public class TransportConnection implements Connection, Task, CommandVisitor {
if (TRANSPORTLOG.isDebugEnabled()) { if (TRANSPORTLOG.isDebugEnabled()) {
TRANSPORTLOG.debug("{} failed: {}", this, e.getMessage(), e); TRANSPORTLOG.debug("{} failed: {}", this, e.getMessage(), e);
} else if (TRANSPORTLOG.isWarnEnabled() && !suppressed(e)) { } else if (TRANSPORTLOG.isWarnEnabled() && !suppressed(e)) {
if (connector.isDisplayStackTrace()) {
TRANSPORTLOG.warn("{} failed", this, e); TRANSPORTLOG.warn("{} failed", this, e);
} else {
TRANSPORTLOG.warn("{} failed: {}", this, e.getMessage());
}
} }
stopAsync(e); stopAsync(e);
} }
} }
private boolean suppressed(IOException e) { private boolean suppressed(IOException e) {
return (isStomp() || !connector.isWarnOnRemoteClose()) && ((e instanceof SocketException && e.getMessage().indexOf("reset") != -1) || e instanceof EOFException); return (!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;
} }
/** /**

View File

@ -78,6 +78,7 @@ public class TransportConnector implements Connector, BrokerServiceAware {
private PublishedAddressPolicy publishedAddressPolicy = new PublishedAddressPolicy(); private PublishedAddressPolicy publishedAddressPolicy = new PublishedAddressPolicy();
private boolean allowLinkStealing = false; private boolean allowLinkStealing = false;
private boolean warnOnRemoteClose = false; private boolean warnOnRemoteClose = false;
private boolean displayStackTrace = false;
LinkedList<String> peerBrokers = new LinkedList<String>(); LinkedList<String> peerBrokers = new LinkedList<String>();
@ -664,4 +665,12 @@ public class TransportConnector implements Connector, BrokerServiceAware {
public void setWarnOnRemoteClose(boolean warnOnRemoteClose) { public void setWarnOnRemoteClose(boolean warnOnRemoteClose) {
this.warnOnRemoteClose = warnOnRemoteClose; this.warnOnRemoteClose = warnOnRemoteClose;
} }
public boolean isDisplayStackTrace() {
return displayStackTrace;
}
public void setDisplayStackTrace(boolean displayStackTrace) {
this.displayStackTrace = displayStackTrace;
}
} }