Skip to content

Commit 6b33acb

Browse files
author
Raju Kumar Gupta
committed
[POOL-419] Fix for POOL-419. Make sure that the state of the pooled object is not invalid before returning back to the pool.
1 parent ae9cc48 commit 6b33acb

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

src/test/java/org/apache/commons/pool3/impl/TestGenericObjectPool.java

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3197,25 +3197,31 @@ void testPool419() throws Exception{
31973197

31983198
List<Object> poolObjects = new ArrayList<>();
31993199

3200-
List<FutureTask<Boolean>> tasks = new ArrayList<>();
3200+
List<Runnable> tasks = new ArrayList<>();
32013201

32023202
for (int i = 0; i < maxConnections; i++) {
32033203
poolObjects.add(connectionPool.borrowObject());
32043204
}
32053205

32063206
for(Object poolObject : poolObjects) {
32073207

3208-
tasks.add(new FutureTask<>(() -> {
3209-
startLatch.await();
3210-
connectionPool.invalidateObject(poolObject);
3211-
return true;
3212-
}));
3213-
3214-
tasks.add(new FutureTask<>(() -> {
3215-
startLatch.await();
3216-
connectionPool.returnObject(poolObject);
3217-
return true;
3218-
}));
3208+
tasks.add(() -> {
3209+
try {
3210+
startLatch.await();
3211+
connectionPool.invalidateObject(poolObject);
3212+
} catch (InterruptedException e) {
3213+
Thread.currentThread().interrupt(); // Restore interrupt status
3214+
}
3215+
});
3216+
3217+
tasks.add(() -> {
3218+
try {
3219+
startLatch.await();
3220+
connectionPool.returnObject(poolObject);
3221+
} catch (InterruptedException e) {
3222+
Thread.currentThread().interrupt(); // Restore interrupt status
3223+
}
3224+
});
32193225
}
32203226

32213227
tasks.forEach(executor::submit);

0 commit comments

Comments
 (0)