Skip to content

Commit

Permalink
Be careful to initialize ConnectionTester to configured class or (now…
Browse files Browse the repository at this point in the history
… default) null.
  • Loading branch information
swaldman committed Feb 28, 2024
1 parent c1af7bb commit 7b46c50
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/com/mchange/v2/c3p0/WrapperConnectionPoolDataSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public final class WrapperConnectionPoolDataSource extends WrapperConnectionPool
final static MLogger logger = MLog.getLogger( WrapperConnectionPoolDataSource.class );

//MT: protected by this' lock
ConnectionTester connectionTester = null;
ConnectionTester connectionTester;
Map userOverrides;

public WrapperConnectionPoolDataSource(boolean autoregister)
Expand All @@ -33,6 +33,16 @@ public WrapperConnectionPoolDataSource(boolean autoregister)

setUpPropertyListeners();

// set up initial value of connectionTester,
// if connectionTesterClassName is null,
// will initialize connectionTester to null
try { recreateConnectionTester( this.getConnectionTesterClassName() ); }
catch (Exception e)
{
if ( logger.isLoggable( MLevel.WARNING ) )
logger.log( MLevel.WARNING, "Failed to construct initial ConnectionTester of type " + this.getConnectionTesterClassName() + "; backing off to null and default isValid(...) test!", e );
}

//set up initial value of userOverrides
try
{ this.userOverrides = C3P0ImplUtils.parseUserOverridesAsString( this.getUserOverridesAsString() ); }
Expand Down

0 comments on commit 7b46c50

Please sign in to comment.