Skip to content

Commit

Permalink
Issue #5121 - always use isDebugEnabled() check before debug logging …
Browse files Browse the repository at this point in the history
…in WebSocket (#5123)

* Issue #5121 - always use isDebugEnabled() check before logging in CompressExtension

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>

* Issue #5121 - always use isDebugEnabled() check before debug logging

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>

* Issue #5121 - always use isDebugEnabled() check before debug logging in WebSocket

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
  • Loading branch information
lachlan-roberts committed Aug 11, 2020
1 parent 4957c09 commit cbd4c38
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 33 deletions.
Expand Up @@ -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;
}
Expand Down
Expand Up @@ -143,15 +143,17 @@ public boolean isRsv3User()

protected void nextIncomingFrame(Frame frame)
{
log.debug("nextIncomingFrame({})", frame);
if (log.isDebugEnabled())
log.debug("nextIncomingFrame({})", frame);
this.nextIncoming.incomingFrame(frame);
}

protected void nextOutgoingFrame(Frame frame, WriteCallback callback, BatchMode batchMode)
{
try
{
log.debug("nextOutgoingFrame({})", frame);
if (log.isDebugEnabled())
log.debug("nextOutgoingFrame({})", frame);
this.nextOutgoing.outgoingFrame(frame, callback, batchMode);
}
catch (Throwable t)
Expand Down
Expand Up @@ -230,17 +230,20 @@ public void negotiate(List<ExtensionConfig> 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;
}

Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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);
}
}
}
Expand Down
Expand Up @@ -193,7 +193,8 @@ protected void decompress(ByteAccumulator accumulator, ByteBuffer buf) throws Da
{
if (!supplyInput(inflater, buf))
{
LOG.debug("Needed input, but no buffer could supply input");
if (LOG.isDebugEnabled())
LOG.debug("Needed input, but no buffer could supply input");
return;
}

Expand All @@ -202,26 +203,22 @@ protected void decompress(ByteAccumulator accumulator, ByteBuffer buf) throws Da
{
if (read == 0)
{
LOG.debug("Decompress: read 0 {}", toDetail(inflater));
if (LOG.isDebugEnabled())
LOG.debug("Decompress: read 0 {}", toDetail(inflater));
break;
}
else
{
// do something with output
if (LOG.isDebugEnabled())
{
LOG.debug("Decompressed {} bytes: {}", read, toDetail(inflater));
}

accumulator.copyChunk(output, 0, read);
}
}
}

if (LOG.isDebugEnabled())
{
LOG.debug("Decompress: exiting {}", toDetail(inflater));
}
}

@Override
Expand Down Expand Up @@ -293,9 +290,7 @@ private static boolean supplyInput(Inflater inflater, ByteBuffer buf)
if (buf == null || buf.remaining() <= 0)
{
if (LOG.isDebugEnabled())
{
LOG.debug("No data left left to supply to Inflater");
}
return false;
}

Expand All @@ -322,9 +317,7 @@ private static boolean supplyInput(Inflater inflater, ByteBuffer buf)

inflater.setInput(input, inputOffset, len);
if (LOG.isDebugEnabled())
{
LOG.debug("Supplied {} input bytes: {}", input.length, toDetail(inflater));
}
return true;
}

Expand All @@ -333,9 +326,7 @@ private static boolean supplyInput(Deflater deflater, ByteBuffer buf)
if (buf == null || buf.remaining() <= 0)
{
if (LOG.isDebugEnabled())
{
LOG.debug("No data left left to supply to Deflater");
}
return false;
}

Expand All @@ -362,9 +353,7 @@ private static boolean supplyInput(Deflater deflater, ByteBuffer buf)

deflater.setInput(input, inputOffset, len);
if (LOG.isDebugEnabled())
{
LOG.debug("Supplied {} input bytes: {}", input.length, toDetail(deflater));
}
return true;
}

Expand Down Expand Up @@ -462,7 +451,8 @@ protected Action process() throws Exception
if (finished)
{
current = pollEntry();
LOG.debug("Processing {}", current);
if (LOG.isDebugEnabled())
LOG.debug("Processing {}", current);
if (current == null)
return Action.IDLE;
deflate(current);
Expand Down Expand Up @@ -570,9 +560,7 @@ else if (fin)
}

if (LOG.isDebugEnabled())
{
LOG.debug("Compressed {}: input:{} -> payload:{}", entry, outputLength, payload.remaining());
}

boolean continuation = frame.getType().isContinuation() || !first;
DataFrame chunk = new DataFrame(frame, continuation);
Expand Down
Expand Up @@ -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();
}
Expand All @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down
Expand Up @@ -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
Expand Down
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down

0 comments on commit cbd4c38

Please sign in to comment.