Skip to content

Commit 1ed27d5

Browse files
committed
Avoid overhead from excessive trace level logging in JdbcCoordinatorImpl
1 parent 22f20d8 commit 1ed27d5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcCoordinatorImpl.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
*/
5050
public class JdbcCoordinatorImpl implements JdbcCoordinator {
5151
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( JdbcCoordinatorImpl.class );
52+
private static final boolean TRACE_ENABLED = LOG.isTraceEnabled();
5253

5354
private transient final LogicalConnectionImplementor logicalConnection;
5455
private transient final JdbcSessionOwner owner;
@@ -141,7 +142,7 @@ public void flushEnding() {
141142

142143
@Override
143144
public Connection close() {
144-
LOG.tracev( "Closing JDBC container [{0}]", this );
145+
if ( TRACE_ENABLED ) LOG.tracev( "Closing JDBC container [{0}]", this );
145146
Connection connection;
146147
try {
147148
if ( currentBatch != null ) {
@@ -264,7 +265,7 @@ public int determineRemainingTransactionTimeOutPeriod() {
264265
@Override
265266
public void afterStatementExecution() {
266267
final ConnectionReleaseMode connectionReleaseMode = connectionReleaseMode();
267-
LOG.tracev( "Starting after statement execution processing [{0}]", connectionReleaseMode );
268+
if ( TRACE_ENABLED ) LOG.tracev( "Starting after statement execution processing [{0}]", connectionReleaseMode );
268269
if ( connectionReleaseMode == AFTER_STATEMENT ) {
269270
if ( ! releasesEnabled ) {
270271
LOG.debug( "Skipping aggressive release due to manual disabling" );
@@ -320,7 +321,7 @@ public boolean isReadyForSerialization() {
320321
@Override
321322
@SuppressWarnings("unchecked")
322323
public void registerLastQuery(Statement statement) {
323-
LOG.tracev( "Registering last query statement [{0}]", statement );
324+
if ( TRACE_ENABLED ) LOG.tracev( "Registering last query statement [{0}]", statement );
324325
if ( statement instanceof JdbcWrapper ) {
325326
final JdbcWrapper<Statement> wrapper = (JdbcWrapper<Statement>) statement;
326327
registerLastQuery( wrapper.getWrappedObject() );

0 commit comments

Comments
 (0)