mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-08 20:24:46 +00:00
HHH-14316 Avoid accessing state in DriverManagerConnectionProviderImpl if null
This commit is contained in:
parent
1c6e2b4efb
commit
a393cbd7f5
@ -168,11 +168,17 @@ private static Driver loadDriverIfPossible(String driverClassName, ServiceRegist
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Connection getConnection() throws SQLException {
|
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();
|
return state.getConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void closeConnection(Connection conn) throws SQLException {
|
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 );
|
state.closeConnection( conn );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,13 +210,17 @@ public <T> T unwrap(Class<T> unwrapType) {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stop() {
|
public void stop() {
|
||||||
state.stop();
|
if ( state != null ) {
|
||||||
|
state.stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//CHECKSTYLE:START_ALLOW_FINALIZER
|
//CHECKSTYLE:START_ALLOW_FINALIZER
|
||||||
@Override
|
@Override
|
||||||
protected void finalize() throws Throwable {
|
protected void finalize() throws Throwable {
|
||||||
state.stop();
|
if ( state != null ) {
|
||||||
|
state.stop();
|
||||||
|
}
|
||||||
super.finalize();
|
super.finalize();
|
||||||
}
|
}
|
||||||
//CHECKSTYLE:END_ALLOW_FINALIZER
|
//CHECKSTYLE:END_ALLOW_FINALIZER
|
||||||
|
Loading…
x
Reference in New Issue
Block a user