Skip to content

Commit

Permalink
[POOL-419] Fix for POOL-419. Before adding the returned object to the…
Browse files Browse the repository at this point in the history
… pool, we must check whether it is invalid.
  • Loading branch information
Raju Kumar Gupta committed Feb 3, 2025
1 parent 6014819 commit 0c2961f
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/test/java/org/apache/commons/pool3/TestPoolUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -705,9 +705,11 @@ void testPool419() throws Exception{

final GenericObjectPoolConfig<Object> config = new GenericObjectPoolConfig<>();

config.setMaxTotal(1000);
config.setMaxIdle(1000);
config.setMinIdle(1000);
final int maxConnections = 10000;

config.setMaxTotal(maxConnections);
config.setMaxIdle(maxConnections);
config.setMinIdle(1);

@SuppressWarnings("unchecked")
final PooledObjectFactory<Object, RuntimeException> pof = createProxy(PooledObjectFactory.class, calledMethods);
Expand All @@ -720,7 +722,7 @@ void testPool419() throws Exception{

List<FutureTask<Boolean>> tasks = new ArrayList<>();

for (int i = 0; i < 1000; i++) {
for (int i = 0; i < maxConnections; i++) {
poolObjects.add(connectionPool.borrowObject());
}

Expand All @@ -739,10 +741,7 @@ void testPool419() throws Exception{
}));
}


for(FutureTask<Boolean> task : tasks) {
executor.submit(task);
}
tasks.forEach(executor::submit);

startLatch.countDown(); // Start all tasks simultaneously

Expand Down

0 comments on commit 0c2961f

Please sign in to comment.