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,6 +351,7 @@ public class WebSocketSession extends ContainerLifeCycle implements Session, Rem
}
catch (Throwable x)
{
if (LOG.isDebugEnabled())
LOG.debug("Exception while notifying failure of callback " + callback, x);
}
return;

View File

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

View File

@ -230,16 +230,19 @@ public class ExtensionStack extends ContainerLifeCycle implements IncomingFrames
// Check RSV
if (ext.isRsv1User() && (rsvClaims[0] != null))
{
if (LOG.isDebugEnabled())
LOG.debug("Not adding extension {}. Extension {} already claimed RSV1", config, rsvClaims[0]);
continue;
}
if (ext.isRsv2User() && (rsvClaims[1] != null))
{
if (LOG.isDebugEnabled())
LOG.debug("Not adding extension {}. Extension {} already claimed RSV2", config, rsvClaims[1]);
continue;
}
if (ext.isRsv3User() && (rsvClaims[2] != null))
{
if (LOG.isDebugEnabled())
LOG.debug("Not adding extension {}. Extension {} already claimed RSV3", config, rsvClaims[2]);
continue;
}
@ -445,6 +448,7 @@ public class ExtensionStack extends ContainerLifeCycle implements IncomingFrames
}
catch (Throwable x)
{
if (LOG.isDebugEnabled())
LOG.debug("Exception while notifying success of callback " + callback, x);
}
}
@ -458,6 +462,7 @@ public class ExtensionStack extends ContainerLifeCycle implements IncomingFrames
}
catch (Throwable x)
{
if (LOG.isDebugEnabled())
LOG.debug("Exception while notifying failure of callback " + callback, x);
}
}

View File

@ -193,6 +193,7 @@ public abstract class CompressExtension extends AbstractExtension
{
if (!supplyInput(inflater, buf))
{
if (LOG.isDebugEnabled())
LOG.debug("Needed input, but no buffer could supply input");
return;
}
@ -202,6 +203,7 @@ public abstract class CompressExtension extends AbstractExtension
{
if (read == 0)
{
if (LOG.isDebugEnabled())
LOG.debug("Decompress: read 0 {}", toDetail(inflater));
break;
}
@ -209,20 +211,15 @@ public abstract class CompressExtension extends AbstractExtension
{
// 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
public void outgoingFrame(Frame frame, WriteCallback callback, BatchMode batchMode)
@ -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,6 +451,7 @@ public abstract class CompressExtension extends AbstractExtension
if (finished)
{
current = pollEntry();
if (LOG.isDebugEnabled())
LOG.debug("Processing {}", current);
if (current == null)
return Action.IDLE;
@ -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,6 +105,7 @@ public class PerMessageDeflateExtension extends CompressExtension
{
if (frame.isFin() && !incomingContextTakeover)
{
if (LOG.isDebugEnabled())
LOG.debug("Incoming Context Reset");
decompressCount.set(0);
getInflater().reset();
@ -117,6 +118,7 @@ public class PerMessageDeflateExtension extends CompressExtension
{
if (frame.isFin() && !outgoingContextTakeover)
{
if (LOG.isDebugEnabled())
LOG.debug("Outgoing Context Reset");
getDeflater().reset();
}
@ -188,6 +190,7 @@ public class PerMessageDeflateExtension extends CompressExtension
}
}
if (LOG.isDebugEnabled())
LOG.debug("config: outgoingContextTakeover={}, incomingContextTakeover={} : {}", outgoingContextTakeover, incomingContextTakeover, this);
super.setConfig(configNegotiated);

View File

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

View File

@ -200,6 +200,7 @@ public class WebSocketUpgradeFilter implements Filter, MappedWebSocketCreator, D
if (configuration == null)
{
// no configuration, cannot operate
if (LOG.isDebugEnabled())
LOG.debug("WebSocketUpgradeFilter is not operational - missing " + NativeWebSocketConfiguration.class.getName());
chain.doFilter(request, response);
return;
@ -210,6 +211,7 @@ public class WebSocketUpgradeFilter implements Filter, MappedWebSocketCreator, D
if (factory == null)
{
// no factory, cannot operate
if (LOG.isDebugEnabled())
LOG.debug("WebSocketUpgradeFilter is not operational - no WebSocketServletFactory configured");
chain.doFilter(request, response);
return;