Issue #5121 - always use isDebugEnabled() check before debug logging 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>
This commit is contained in:
Lachlan 2020-08-11 19:51:39 +10:00 committed by GitHub
parent 4957c091d0
commit cbd4c38f3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 36 additions and 33 deletions

View File

@ -351,7 +351,8 @@ public class WebSocketSession extends ContainerLifeCycle implements Session, Rem
} }
catch (Throwable x) 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; return;
} }

View File

@ -143,7 +143,8 @@ public abstract class AbstractExtension extends AbstractLifeCycle implements Ext
protected void nextIncomingFrame(Frame frame) protected void nextIncomingFrame(Frame frame)
{ {
log.debug("nextIncomingFrame({})", frame); if (log.isDebugEnabled())
log.debug("nextIncomingFrame({})", frame);
this.nextIncoming.incomingFrame(frame); this.nextIncoming.incomingFrame(frame);
} }
@ -151,7 +152,8 @@ public abstract class AbstractExtension extends AbstractLifeCycle implements Ext
{ {
try try
{ {
log.debug("nextOutgoingFrame({})", frame); if (log.isDebugEnabled())
log.debug("nextOutgoingFrame({})", frame);
this.nextOutgoing.outgoingFrame(frame, callback, batchMode); this.nextOutgoing.outgoingFrame(frame, callback, batchMode);
} }
catch (Throwable t) catch (Throwable t)

View File

@ -230,17 +230,20 @@ public class ExtensionStack extends ContainerLifeCycle implements IncomingFrames
// Check RSV // Check RSV
if (ext.isRsv1User() && (rsvClaims[0] != null)) 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; continue;
} }
if (ext.isRsv2User() && (rsvClaims[1] != null)) 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; continue;
} }
if (ext.isRsv3User() && (rsvClaims[2] != null)) 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; continue;
} }
@ -445,7 +448,8 @@ public class ExtensionStack extends ContainerLifeCycle implements IncomingFrames
} }
catch (Throwable x) 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 @@ public class ExtensionStack extends ContainerLifeCycle implements IncomingFrames
} }
catch (Throwable x) 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);
} }
} }
} }

View File

@ -193,7 +193,8 @@ public abstract class CompressExtension extends AbstractExtension
{ {
if (!supplyInput(inflater, buf)) 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; return;
} }
@ -202,26 +203,22 @@ public abstract class CompressExtension extends AbstractExtension
{ {
if (read == 0) if (read == 0)
{ {
LOG.debug("Decompress: read 0 {}", toDetail(inflater)); if (LOG.isDebugEnabled())
LOG.debug("Decompress: read 0 {}", toDetail(inflater));
break; break;
} }
else else
{ {
// do something with output // do something with output
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
{
LOG.debug("Decompressed {} bytes: {}", read, toDetail(inflater)); LOG.debug("Decompressed {} bytes: {}", read, toDetail(inflater));
}
accumulator.copyChunk(output, 0, read); accumulator.copyChunk(output, 0, read);
} }
} }
} }
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
{
LOG.debug("Decompress: exiting {}", toDetail(inflater)); LOG.debug("Decompress: exiting {}", toDetail(inflater));
}
} }
@Override @Override
@ -293,9 +290,7 @@ public abstract class CompressExtension extends AbstractExtension
if (buf == null || buf.remaining() <= 0) if (buf == null || buf.remaining() <= 0)
{ {
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
{
LOG.debug("No data left left to supply to Inflater"); LOG.debug("No data left left to supply to Inflater");
}
return false; return false;
} }
@ -322,9 +317,7 @@ public abstract class CompressExtension extends AbstractExtension
inflater.setInput(input, inputOffset, len); inflater.setInput(input, inputOffset, len);
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
{
LOG.debug("Supplied {} input bytes: {}", input.length, toDetail(inflater)); LOG.debug("Supplied {} input bytes: {}", input.length, toDetail(inflater));
}
return true; return true;
} }
@ -333,9 +326,7 @@ public abstract class CompressExtension extends AbstractExtension
if (buf == null || buf.remaining() <= 0) if (buf == null || buf.remaining() <= 0)
{ {
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
{
LOG.debug("No data left left to supply to Deflater"); LOG.debug("No data left left to supply to Deflater");
}
return false; return false;
} }
@ -362,9 +353,7 @@ public abstract class CompressExtension extends AbstractExtension
deflater.setInput(input, inputOffset, len); deflater.setInput(input, inputOffset, len);
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
{
LOG.debug("Supplied {} input bytes: {}", input.length, toDetail(deflater)); LOG.debug("Supplied {} input bytes: {}", input.length, toDetail(deflater));
}
return true; return true;
} }
@ -462,7 +451,8 @@ public abstract class CompressExtension extends AbstractExtension
if (finished) if (finished)
{ {
current = pollEntry(); current = pollEntry();
LOG.debug("Processing {}", current); if (LOG.isDebugEnabled())
LOG.debug("Processing {}", current);
if (current == null) if (current == null)
return Action.IDLE; return Action.IDLE;
deflate(current); deflate(current);
@ -570,9 +560,7 @@ public abstract class CompressExtension extends AbstractExtension
} }
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
{
LOG.debug("Compressed {}: input:{} -> payload:{}", entry, outputLength, payload.remaining()); LOG.debug("Compressed {}: input:{} -> payload:{}", entry, outputLength, payload.remaining());
}
boolean continuation = frame.getType().isContinuation() || !first; boolean continuation = frame.getType().isContinuation() || !first;
DataFrame chunk = new DataFrame(frame, continuation); DataFrame chunk = new DataFrame(frame, continuation);

View File

@ -105,7 +105,8 @@ public class PerMessageDeflateExtension extends CompressExtension
{ {
if (frame.isFin() && !incomingContextTakeover) if (frame.isFin() && !incomingContextTakeover)
{ {
LOG.debug("Incoming Context Reset"); if (LOG.isDebugEnabled())
LOG.debug("Incoming Context Reset");
decompressCount.set(0); decompressCount.set(0);
getInflater().reset(); getInflater().reset();
} }
@ -117,7 +118,8 @@ public class PerMessageDeflateExtension extends CompressExtension
{ {
if (frame.isFin() && !outgoingContextTakeover) if (frame.isFin() && !outgoingContextTakeover)
{ {
LOG.debug("Outgoing Context Reset"); if (LOG.isDebugEnabled())
LOG.debug("Outgoing Context Reset");
getDeflater().reset(); getDeflater().reset();
} }
super.nextOutgoingFrame(frame, callback, batchMode); super.nextOutgoingFrame(frame, callback, batchMode);
@ -188,7 +190,8 @@ public class PerMessageDeflateExtension extends CompressExtension
} }
} }
LOG.debug("config: outgoingContextTakeover={}, incomingContextTakeover={} : {}", outgoingContextTakeover, incomingContextTakeover, this); if (LOG.isDebugEnabled())
LOG.debug("config: outgoingContextTakeover={}, incomingContextTakeover={} : {}", outgoingContextTakeover, incomingContextTakeover, this);
super.setConfig(configNegotiated); super.setConfig(configNegotiated);
} }

View File

@ -130,10 +130,12 @@ public class FragmentExtension extends AbstractExtension
current = pollEntry(); current = pollEntry();
if (current == null) if (current == null)
{ {
LOG.debug("Processing IDLE", current); if (LOG.isDebugEnabled())
LOG.debug("Processing IDLE", current);
return Action.IDLE; return Action.IDLE;
} }
LOG.debug("Processing {}", current); if (LOG.isDebugEnabled())
LOG.debug("Processing {}", current);
fragment(current, true); fragment(current, true);
} }
else else

View File

@ -200,7 +200,8 @@ public class WebSocketUpgradeFilter implements Filter, MappedWebSocketCreator, D
if (configuration == null) if (configuration == null)
{ {
// no configuration, cannot operate // 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); chain.doFilter(request, response);
return; return;
} }
@ -210,7 +211,8 @@ public class WebSocketUpgradeFilter implements Filter, MappedWebSocketCreator, D
if (factory == null) if (factory == null)
{ {
// no factory, cannot operate // 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); chain.doFilter(request, response);
return; return;
} }