HHH-7699 More aggressive in checking log levels before creating log messages
This commit is contained in:
parent
e27afb8ded
commit
e4300d279c
|
@ -169,13 +169,14 @@ public class DriverManagerConnectionProviderImpl
|
||||||
}
|
}
|
||||||
|
|
||||||
public Connection getConnection() throws SQLException {
|
public Connection getConnection() throws SQLException {
|
||||||
LOG.tracev( "Total checked-out connections: {0}", checkedOut );
|
final boolean traceEnabled = LOG.isTraceEnabled();
|
||||||
|
if ( traceEnabled ) LOG.tracev( "Total checked-out connections: {0}", checkedOut );
|
||||||
|
|
||||||
// essentially, if we have available connections in the pool, use one...
|
// essentially, if we have available connections in the pool, use one...
|
||||||
synchronized (pool) {
|
synchronized (pool) {
|
||||||
if ( !pool.isEmpty() ) {
|
if ( !pool.isEmpty() ) {
|
||||||
int last = pool.size() - 1;
|
int last = pool.size() - 1;
|
||||||
LOG.tracev( "Using pooled JDBC connection, pool size: {0}", last );
|
if ( traceEnabled ) LOG.tracev( "Using pooled JDBC connection, pool size: {0}", last );
|
||||||
Connection pooled = pool.remove( last );
|
Connection pooled = pool.remove( last );
|
||||||
if ( isolation != null ) {
|
if ( isolation != null ) {
|
||||||
pooled.setTransactionIsolation( isolation.intValue() );
|
pooled.setTransactionIsolation( isolation.intValue() );
|
||||||
|
@ -190,7 +191,9 @@ public class DriverManagerConnectionProviderImpl
|
||||||
|
|
||||||
// otherwise we open a new connection...
|
// otherwise we open a new connection...
|
||||||
|
|
||||||
LOG.debug( "Opening new JDBC connection" );
|
final boolean debugEnabled = LOG.isDebugEnabled();
|
||||||
|
if ( debugEnabled ) LOG.debug( "Opening new JDBC connection" );
|
||||||
|
|
||||||
Connection conn = DriverManager.getConnection( url, connectionProps );
|
Connection conn = DriverManager.getConnection( url, connectionProps );
|
||||||
if ( isolation != null ) {
|
if ( isolation != null ) {
|
||||||
conn.setTransactionIsolation( isolation.intValue() );
|
conn.setTransactionIsolation( isolation.intValue() );
|
||||||
|
@ -199,7 +202,7 @@ public class DriverManagerConnectionProviderImpl
|
||||||
conn.setAutoCommit(autocommit);
|
conn.setAutoCommit(autocommit);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( LOG.isDebugEnabled() ) {
|
if ( debugEnabled ) {
|
||||||
LOG.debugf( "Created connection to: %s, Isolation Level: %s", url, conn.getTransactionIsolation() );
|
LOG.debugf( "Created connection to: %s, Isolation Level: %s", url, conn.getTransactionIsolation() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,11 +213,12 @@ public class DriverManagerConnectionProviderImpl
|
||||||
public void closeConnection(Connection conn) throws SQLException {
|
public void closeConnection(Connection conn) throws SQLException {
|
||||||
checkedOut--;
|
checkedOut--;
|
||||||
|
|
||||||
|
final boolean traceEnabled = LOG.isTraceEnabled();
|
||||||
// add to the pool if the max size is not yet reached.
|
// add to the pool if the max size is not yet reached.
|
||||||
synchronized ( pool ) {
|
synchronized ( pool ) {
|
||||||
int currentSize = pool.size();
|
int currentSize = pool.size();
|
||||||
if ( currentSize < poolSize ) {
|
if ( currentSize < poolSize ) {
|
||||||
LOG.tracev( "Returning connection to pool, pool size: {0}", ( currentSize + 1 ) );
|
if ( traceEnabled ) LOG.tracev( "Returning connection to pool, pool size: {0}", ( currentSize + 1 ) );
|
||||||
pool.add( conn );
|
pool.add( conn );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue