Migliorato shutdown BasicConnectionPool
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
This commit is contained in:
@@ -36,6 +36,8 @@ public class BasicConnectionPool {
|
|||||||
|
|
||||||
private final ReentrantLock poolLock = new ReentrantLock();
|
private final ReentrantLock poolLock = new ReentrantLock();
|
||||||
|
|
||||||
|
private boolean shuttingDown = false;
|
||||||
|
|
||||||
public void init() throws Exception {
|
public void init() throws Exception {
|
||||||
poolLock.lock();
|
poolLock.lock();
|
||||||
try {
|
try {
|
||||||
@@ -50,6 +52,7 @@ public class BasicConnectionPool {
|
|||||||
@PreDestroy
|
@PreDestroy
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
logger.info("Shutting down connection pool");
|
logger.info("Shutting down connection pool");
|
||||||
|
shuttingDown = true;
|
||||||
closeAllConnections();
|
closeAllConnections();
|
||||||
logger.info("Connection pool shut down successfully");
|
logger.info("Connection pool shut down successfully");
|
||||||
}
|
}
|
||||||
@@ -177,7 +180,7 @@ public class BasicConnectionPool {
|
|||||||
|
|
||||||
poolLock.lock();
|
poolLock.lock();
|
||||||
try {
|
try {
|
||||||
String currentCatalog = ds.getConnection().getCatalog();
|
String currentCatalog = shuttingDown ? ds.getDbName() : ds.getConnection().getCatalog();
|
||||||
AvailableConnectionsModel model = findConnectionModel(profileName);
|
AvailableConnectionsModel model = findConnectionModel(profileName);
|
||||||
|
|
||||||
if (model == null) {
|
if (model == null) {
|
||||||
@@ -189,7 +192,7 @@ public class BasicConnectionPool {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return handleConnectionRelease(ds);
|
return shuttingDown || handleConnectionRelease(ds);
|
||||||
} finally {
|
} finally {
|
||||||
poolLock.unlock();
|
poolLock.unlock();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user