mirror of
https://github.com/Qortal/qortal.git
synced 2025-02-14 11:15:49 +00:00
Fix minor NPE during shutdown
This commit is contained in:
parent
385064e324
commit
190014cf96
@ -21,18 +21,28 @@ public class HSQLDBPool extends JDBCPool {
|
|||||||
public Connection tryConnection() throws SQLException {
|
public Connection tryConnection() throws SQLException {
|
||||||
for (int i = 0; i < states.length(); i++) {
|
for (int i = 0; i < states.length(); i++) {
|
||||||
if (states.compareAndSet(i, RefState.available, RefState.allocated)) {
|
if (states.compareAndSet(i, RefState.available, RefState.allocated)) {
|
||||||
return connections[i].getConnection();
|
JDBCPooledConnection pooledConnection = connections[i];
|
||||||
|
|
||||||
|
if (pooledConnection == null)
|
||||||
|
// Probably shutdown situation
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return pooledConnection.getConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (states.compareAndSet(i, RefState.empty, RefState.allocated)) {
|
if (states.compareAndSet(i, RefState.empty, RefState.allocated)) {
|
||||||
try {
|
try {
|
||||||
JDBCPooledConnection connection = (JDBCPooledConnection) source.getPooledConnection();
|
JDBCPooledConnection pooledConnection = (JDBCPooledConnection) source.getPooledConnection();
|
||||||
|
|
||||||
connection.addConnectionEventListener(this);
|
if (pooledConnection == null)
|
||||||
connection.addStatementEventListener(this);
|
// Probably shutdown situation
|
||||||
connections[i] = connection;
|
return null;
|
||||||
|
|
||||||
return connections[i].getConnection();
|
pooledConnection.addConnectionEventListener(this);
|
||||||
|
pooledConnection.addStatementEventListener(this);
|
||||||
|
connections[i] = pooledConnection;
|
||||||
|
|
||||||
|
return pooledConnection.getConnection();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
states.set(i, RefState.empty);
|
states.set(i, RefState.empty);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user