Bug 53199

Summary: Refactor ConnectionPool to use ScheduledExecutorService instead of TimerTask
Product: Tomcat Modules Reporter: Patric Rufflar <patric>
Component: jdbc-poolAssignee: Tomcat Developers Mailing List <dev>
Status: NEEDINFO ---    
Severity: enhancement    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: All   

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.