Bug 53199 - Refactor ConnectionPool to use ScheduledExecutorService instead of TimerTask
Summary: Refactor ConnectionPool to use ScheduledExecutorService instead of TimerTask
Alias: None
Product: Tomcat Modules
Classification: Unclassified
Component: jdbc-pool (show other bugs)
Version: unspecified
Hardware: PC All
: P2 enhancement (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2012-05-07 16:15 UTC by Patric Rufflar
Modified: 2012-09-26 11:28 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Patric Rufflar 2012-05-07 16:15:31 UTC
ConnectionPool should be refactored to use a ScheduledExecutorService instead of a TimerTask.

This would enable providing a custom ScheduledExecutorService to jdbc pool to reduce expensive thread creation in certain environments
(in my case: junit tests, where each test case will get a new environment, including a ConnectionPool)
Comment 1 Filip Hanik 2012-05-07 19:24:03 UTC
hi Patric, I'm all for this. If you have a patch for this to get us started that would be great.

The requirements for the default implementation are

1. No more than 1 thread should ever be started for this task

2. The thread has to be created with the class loader of the library, not of the thread (context classloader)

3. When the last pool is closed that is using the cleaner is closed, the thread should also go away
Comment 2 Patric Rufflar 2012-09-26 11:28:43 UTC
I just want to add that the current (TimerTask) implementation seems to have a bug which causes that the PoolCleaner Thread will not be terminated/canceled in some cases.
I am currently unable to reproduce this but I saw this issue several times.