Skip to content

Commit

Permalink
HHH-14316 Avoid accessing state in DriverManagerConnectionProviderImp…
Browse files Browse the repository at this point in the history
…l if null
  • Loading branch information
gsmet authored and Sanne committed Nov 9, 2020
1 parent 1c6e2b4 commit a393cbd
Showing 1 changed file with 12 additions and 2 deletions.
Expand Up @@ -168,11 +168,17 @@ private static Driver loadDriverIfPossible(String driverClassName, ServiceRegist

@Override
public Connection getConnection() throws SQLException {
if ( state == null ) {
throw new IllegalStateException( "Cannot get a connection as the driver manager is not properly initialized" );
}
return state.getConnection();
}

@Override
public void closeConnection(Connection conn) throws SQLException {
if ( state == null ) {
throw new IllegalStateException( "Cannot close a connection as the driver manager is not properly initialized" );
}
state.closeConnection( conn );
}

Expand Down Expand Up @@ -204,13 +210,17 @@ public <T> T unwrap(Class<T> unwrapType) {

@Override
public void stop() {
state.stop();
if ( state != null ) {
state.stop();
}
}

//CHECKSTYLE:START_ALLOW_FINALIZER
@Override
protected void finalize() throws Throwable {
state.stop();
if ( state != null ) {
state.stop();
}
super.finalize();
}
//CHECKSTYLE:END_ALLOW_FINALIZER
Expand Down

0 comments on commit a393cbd

Please sign in to comment.