Removed caching of debug log level.

It is useful to be able to change the log level via JMX for debugging purposes.
This commit is contained in:
Simone Bordet 2016-01-04 12:46:43 +01:00
parent fdadc942e9
commit 6d1027eaff
1 changed files with 14 additions and 15 deletions

View File

@ -77,7 +77,6 @@ import org.eclipse.jetty.util.log.Logger;
public class SslConnection extends AbstractConnection
{
private static final Logger LOG = Log.getLogger(SslConnection.class);
private static final boolean DEBUG = LOG.isDebugEnabled(); // Easy for the compiler to remove the code if DEBUG==false
private static final ByteBuffer __FILL_CALLED_FLUSH= BufferUtil.allocate(0);
private static final ByteBuffer __FLUSH_CALLED_FILL= BufferUtil.allocate(0);
private final ByteBufferPool _bufferPool;
@ -186,7 +185,7 @@ public class SslConnection extends AbstractConnection
// to do the fill and/or flush again and these calls will do the actually
// filling.
if (DEBUG)
if (LOG.isDebugEnabled())
LOG.debug("onFillable enter {}", _decryptedEndPoint);
// We have received a close handshake, close the end point to send FIN.
@ -207,7 +206,7 @@ public class SslConnection extends AbstractConnection
}
}
if (DEBUG)
if (LOG.isDebugEnabled())
LOG.debug("onFillable exit {}", _decryptedEndPoint);
}
@ -270,7 +269,7 @@ public class SslConnection extends AbstractConnection
boolean fillable = false;
synchronized (DecryptedEndPoint.this)
{
if (DEBUG)
if (LOG.isDebugEnabled())
LOG.debug("write.complete {}", SslConnection.this.getEndPoint());
releaseEncryptedOutputBuffer();
@ -297,7 +296,7 @@ public class SslConnection extends AbstractConnection
boolean fail_filler = false;
synchronized (DecryptedEndPoint.this)
{
if (DEBUG)
if (LOG.isDebugEnabled())
LOG.debug("{} write.failed", SslConnection.this, x);
BufferUtil.clear(_encryptedOutput);
releaseEncryptedOutputBuffer();
@ -373,7 +372,7 @@ public class SslConnection extends AbstractConnection
boolean try_again = false;
synchronized (DecryptedEndPoint.this)
{
if (DEBUG)
if (LOG.isDebugEnabled())
LOG.debug("onIncompleteFlush {}", SslConnection.this);
// If we have pending output data,
if (BufferUtil.hasContent(_encryptedOutput))
@ -530,7 +529,7 @@ public class SslConnection extends AbstractConnection
{
BufferUtil.flipToFlush(app_in, pos);
}
if (DEBUG)
if (LOG.isDebugEnabled())
{
LOG.debug("{} net={} unwrap {}", SslConnection.this, net_filled, unwrapResult.toString().replace('\n',' '));
LOG.debug("{} filled {}",SslConnection.this,BufferUtil.toHexSummary(buffer));
@ -593,7 +592,7 @@ public class SslConnection extends AbstractConnection
if (unwrapHandshakeStatus == HandshakeStatus.FINISHED && !_handshaken)
{
_handshaken = true;
if (DEBUG)
if (LOG.isDebugEnabled())
LOG.debug("{} {} handshook {}/{}", SslConnection.this,
_sslEngine.getUseClientMode() ? "client" : "resumed server",
_sslEngine.getSession().getProtocol(),_sslEngine.getSession().getCipherSuite());
@ -602,7 +601,7 @@ public class SslConnection extends AbstractConnection
// Check whether renegotiation is allowed
if (_handshaken && handshakeStatus != HandshakeStatus.NOT_HANDSHAKING && !isRenegotiationAllowed())
{
if (DEBUG)
if (LOG.isDebugEnabled())
LOG.debug("{} renegotiation denied", SslConnection.this);
closeInbound();
return -1;
@ -729,7 +728,7 @@ public class SslConnection extends AbstractConnection
// it is the applications responsibility to call flush again - either in a busy loop
// or better yet by using EndPoint#write to do the flushing.
if (DEBUG)
if (LOG.isDebugEnabled())
{
for (ByteBuffer b : appOuts)
LOG.debug("{} flush {}", SslConnection.this, BufferUtil.toHexSummary(b));
@ -762,7 +761,7 @@ public class SslConnection extends AbstractConnection
{
BufferUtil.flipToFlush(_encryptedOutput, pos);
}
if (DEBUG)
if (LOG.isDebugEnabled())
LOG.debug("{} wrap {}", SslConnection.this, wrapResult.toString().replace('\n',' '));
Status wrapResultStatus = wrapResult.getStatus();
@ -800,13 +799,13 @@ public class SslConnection extends AbstractConnection
throw new IllegalStateException();
default:
if (DEBUG)
if (LOG.isDebugEnabled())
LOG.debug("{} wrap {} {}", SslConnection.this, wrapResultStatus, BufferUtil.toHexSummary(_encryptedOutput));
if (wrapResult.getHandshakeStatus() == HandshakeStatus.FINISHED && !_handshaken)
{
_handshaken = true;
if (DEBUG)
if (LOG.isDebugEnabled())
LOG.debug("{} server handshook complete {}/{}", SslConnection.this, _sslEngine.getSession().getProtocol(),_sslEngine.getSession().getCipherSuite());
}
@ -815,7 +814,7 @@ public class SslConnection extends AbstractConnection
// Check whether renegotiation is allowed
if (_handshaken && handshakeStatus != HandshakeStatus.NOT_HANDSHAKING && !isRenegotiationAllowed())
{
if (DEBUG)
if (LOG.isDebugEnabled())
LOG.debug("{} renegotiation denied", SslConnection.this);
getEndPoint().shutdownOutput();
return allConsumed;
@ -890,7 +889,7 @@ public class SslConnection extends AbstractConnection
{
boolean ishut = isInputShutdown();
boolean oshut = isOutputShutdown();
if (DEBUG)
if (LOG.isDebugEnabled())
LOG.debug("{} shutdownOutput: oshut={}, ishut={}", SslConnection.this, oshut, ishut);
if (ishut)
{