From e42b41a6b87362a95e44180b1b4f26c04e95565b Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Thu, 6 Aug 2020 21:07:55 +1000 Subject: [PATCH] Issue #5121 - always use isDebugEnabled() check before debug logging in WebSocket Signed-off-by: Lachlan Roberts --- .../eclipse/jetty/websocket/common/WebSocketSession.java | 3 ++- .../extensions/compress/PerMessageDeflateExtension.java | 9 ++++++--- .../jetty/websocket/server/WebSocketUpgradeFilter.java | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketSession.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketSession.java index d0d364608114..268961b7fec1 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketSession.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketSession.java @@ -351,7 +351,8 @@ public void outgoingFrame(Frame frame, WriteCallback callback, BatchMode batchMo } catch (Throwable x) { - LOG.debug("Exception while notifying failure of callback " + callback, x); + if (LOG.isDebugEnabled()) + LOG.debug("Exception while notifying failure of callback " + callback, x); } return; } diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/PerMessageDeflateExtension.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/PerMessageDeflateExtension.java index 931fe4ea1494..37482f8bd678 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/PerMessageDeflateExtension.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/PerMessageDeflateExtension.java @@ -105,7 +105,8 @@ protected void nextIncomingFrame(Frame frame) { if (frame.isFin() && !incomingContextTakeover) { - LOG.debug("Incoming Context Reset"); + if (LOG.isDebugEnabled()) + LOG.debug("Incoming Context Reset"); decompressCount.set(0); getInflater().reset(); } @@ -117,7 +118,8 @@ protected void nextOutgoingFrame(Frame frame, WriteCallback callback, BatchMode { if (frame.isFin() && !outgoingContextTakeover) { - LOG.debug("Outgoing Context Reset"); + if (LOG.isDebugEnabled()) + LOG.debug("Outgoing Context Reset"); getDeflater().reset(); } super.nextOutgoingFrame(frame, callback, batchMode); @@ -188,7 +190,8 @@ public void setConfig(final ExtensionConfig config) } } - LOG.debug("config: outgoingContextTakeover={}, incomingContextTakeover={} : {}", outgoingContextTakeover, incomingContextTakeover, this); + if (LOG.isDebugEnabled()) + LOG.debug("config: outgoingContextTakeover={}, incomingContextTakeover={} : {}", outgoingContextTakeover, incomingContextTakeover, this); super.setConfig(configNegotiated); } diff --git a/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketUpgradeFilter.java b/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketUpgradeFilter.java index 0815501025c4..6138423f1adf 100644 --- a/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketUpgradeFilter.java +++ b/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketUpgradeFilter.java @@ -200,7 +200,8 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha if (configuration == null) { // no configuration, cannot operate - LOG.debug("WebSocketUpgradeFilter is not operational - missing " + NativeWebSocketConfiguration.class.getName()); + if (LOG.isDebugEnabled()) + LOG.debug("WebSocketUpgradeFilter is not operational - missing " + NativeWebSocketConfiguration.class.getName()); chain.doFilter(request, response); return; } @@ -210,7 +211,8 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha if (factory == null) { // no factory, cannot operate - LOG.debug("WebSocketUpgradeFilter is not operational - no WebSocketServletFactory configured"); + if (LOG.isDebugEnabled()) + LOG.debug("WebSocketUpgradeFilter is not operational - no WebSocketServletFactory configured"); chain.doFilter(request, response); return; }