Bug 51583 - ConnectionPool.close() always waits one second unnecessarily
Summary: ConnectionPool.close() always waits one second unnecessarily
Alias: None
Product: Tomcat Modules
Classification: Unclassified
Component: jdbc-pool (show other bugs)
Version: unspecified
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2011-07-29 08:10 UTC by Patric Rufflar
Modified: 2011-08-15 15:19 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Patric Rufflar 2011-07-29 08:10:00 UTC
As discussed with Filip via mail: (just to do report it officially):

I've encountered an issue on closing the pool:
Closing a ConnectionPool will always take at least one second if more than zero connections have been acquired.
Please have a look at ConnectionPool.java:367 :

                    con = pool.poll(1000, TimeUnit.MILLISECONDS);

Imagine that we've previously fetched the last connection out of the queue.
In this case the that command will cause that we've to wait 1000ms (to return null).

The solution would be easy - just check prior to polling if the pool queue is empty.

The 1 second wait time is really annoying because I am creating and destroying the pool for each junit test which causes that each test will take more than 2 seconds (I am using two pools per test).
Comment 1 Filip Hanik 2011-08-15 15:19:48 UTC
Fixed in r1157874