From 4d42069ed961c7e4fb758623c428add3df6dcf3b Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Thu, 6 Aug 2020 15:42:17 +1000 Subject: [PATCH] Issue #5121 - always use isDebugEnabled() check before debug logging Signed-off-by: Lachlan Roberts --- .../common/extensions/AbstractExtension.java | 6 ++++-- .../common/extensions/ExtensionStack.java | 15 ++++++++++----- .../extensions/fragment/FragmentExtension.java | 6 ++++-- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/AbstractExtension.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/AbstractExtension.java index db4eebc6ff8c..e4d704dde566 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/AbstractExtension.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/AbstractExtension.java @@ -143,7 +143,8 @@ public boolean isRsv3User() protected void nextIncomingFrame(Frame frame) { - log.debug("nextIncomingFrame({})", frame); + if (log.isDebugEnabled()) + log.debug("nextIncomingFrame({})", frame); this.nextIncoming.incomingFrame(frame); } @@ -151,7 +152,8 @@ protected void nextOutgoingFrame(Frame frame, WriteCallback callback, BatchMode { try { - log.debug("nextOutgoingFrame({})", frame); + if (log.isDebugEnabled()) + log.debug("nextOutgoingFrame({})", frame); this.nextOutgoing.outgoingFrame(frame, callback, batchMode); } catch (Throwable t) diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/ExtensionStack.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/ExtensionStack.java index 3b19467a1acd..d307e5b8617c 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/ExtensionStack.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/ExtensionStack.java @@ -230,17 +230,20 @@ public void negotiate(List configs) // Check RSV if (ext.isRsv1User() && (rsvClaims[0] != null)) { - LOG.debug("Not adding extension {}. Extension {} already claimed RSV1", config, rsvClaims[0]); + if (LOG.isDebugEnabled()) + LOG.debug("Not adding extension {}. Extension {} already claimed RSV1", config, rsvClaims[0]); continue; } if (ext.isRsv2User() && (rsvClaims[1] != null)) { - LOG.debug("Not adding extension {}. Extension {} already claimed RSV2", config, rsvClaims[1]); + if (LOG.isDebugEnabled()) + LOG.debug("Not adding extension {}. Extension {} already claimed RSV2", config, rsvClaims[1]); continue; } if (ext.isRsv3User() && (rsvClaims[2] != null)) { - LOG.debug("Not adding extension {}. Extension {} already claimed RSV3", config, rsvClaims[2]); + if (LOG.isDebugEnabled()) + LOG.debug("Not adding extension {}. Extension {} already claimed RSV3", config, rsvClaims[2]); continue; } @@ -445,7 +448,8 @@ private void notifyCallbackSuccess(WriteCallback callback) } catch (Throwable x) { - LOG.debug("Exception while notifying success of callback " + callback, x); + if (LOG.isDebugEnabled()) + LOG.debug("Exception while notifying success of callback " + callback, x); } } @@ -458,7 +462,8 @@ private void notifyCallbackFailure(WriteCallback callback, Throwable failure) } 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); } } } diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/fragment/FragmentExtension.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/fragment/FragmentExtension.java index e87eeda319e8..6830605b6a2a 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/fragment/FragmentExtension.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/fragment/FragmentExtension.java @@ -130,10 +130,12 @@ protected Action process() current = pollEntry(); if (current == null) { - LOG.debug("Processing IDLE", current); + if (LOG.isDebugEnabled()) + LOG.debug("Processing IDLE", current); return Action.IDLE; } - LOG.debug("Processing {}", current); + if (LOG.isDebugEnabled()) + LOG.debug("Processing {}", current); fragment(current, true); } else