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)
{
LOG.debug("Exception while notifying failure of callback " + callback, x);
if (LOG.isDebugEnabled())
LOG.debug("Exception while notifying failure of callback " + callback, x);
}
return;
}

View File

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

View File

@ -230,17 +230,20 @@ public class ExtensionStack extends ContainerLifeCycle implements IncomingFrames
// 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 @@ public class ExtensionStack extends ContainerLifeCycle implements IncomingFrames
}
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)
{
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))
{
LOG.debug("Needed input, but no buffer could supply input");
if (LOG.isDebugEnabled())
LOG.debug("Needed input, but no buffer could supply input");
return;
}
@ -202,26 +203,22 @@ public abstract class CompressExtension extends AbstractExtension
{
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
@ -293,9 +290,7 @@ public abstract class CompressExtension extends AbstractExtension
if (buf == null || buf.remaining() <= 0)
{
if (LOG.isDebugEnabled())
{
LOG.debug("No data left left to supply to Inflater");
}
return false;
}
@ -322,9 +317,7 @@ public abstract class CompressExtension extends AbstractExtension
inflater.setInput(input, inputOffset, len);
if (LOG.isDebugEnabled())
{
LOG.debug("Supplied {} input bytes: {}", input.length, toDetail(inflater));
}
return true;
}
@ -333,9 +326,7 @@ public abstract class CompressExtension extends AbstractExtension
if (buf == null || buf.remaining() <= 0)
{
if (LOG.isDebugEnabled())
{
LOG.debug("No data left left to supply to Deflater");
}
return false;
}
@ -362,9 +353,7 @@ public abstract class CompressExtension extends AbstractExtension
deflater.setInput(input, inputOffset, len);
if (LOG.isDebugEnabled())
{
LOG.debug("Supplied {} input bytes: {}", input.length, toDetail(deflater));
}
return true;
}
@ -462,7 +451,8 @@ public abstract class CompressExtension extends AbstractExtension
if (finished)
{
current = pollEntry();
LOG.debug("Processing {}", current);
if (LOG.isDebugEnabled())
LOG.debug("Processing {}", current);
if (current == null)
return Action.IDLE;
deflate(current);
@ -570,9 +560,7 @@ public abstract class CompressExtension extends AbstractExtension
}
if (LOG.isDebugEnabled())
{
LOG.debug("Compressed {}: input:{} -> payload:{}", entry, outputLength, payload.remaining());
}
boolean continuation = frame.getType().isContinuation() || !first;
DataFrame chunk = new DataFrame(frame, continuation);

View File

@ -105,7 +105,8 @@ public class PerMessageDeflateExtension extends CompressExtension
{
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 @@ public class PerMessageDeflateExtension extends CompressExtension
{
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 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);
}

View File

@ -130,10 +130,12 @@ public class FragmentExtension extends AbstractExtension
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

View File

@ -200,7 +200,8 @@ public class WebSocketUpgradeFilter implements Filter, MappedWebSocketCreator, D
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 class WebSocketUpgradeFilter implements Filter, MappedWebSocketCreator, D
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;
}