Resource pool not waiting on destroyer threads
In BasicResourcePool.close() destroyer threads are created, but they are never joined. This causes Tomcat to complain that there are leaking threads. Yes, they will eventually stop running, but close() should join them, so that we don't get the false alarm from Tomcat.
for (Iterator ii = cleanupResources.iterator(); ii.hasNext();)
addToFormerResources( ii.next() );
managed.keySet().removeAll( cleanupResources );
unused.removeAll( cleanupResources );
Thread resourceDestroyer = new Thread("Resource Destroyer in BasicResourcePool.close()")
{
public void run()
{
for (Iterator ii = cleanupResources.iterator(); ii.hasNext();)
{
try
{
Object resc = ii.next();
destroyResource( resc, true );
}
catch (Exception e)
{
if (Debug.DEBUG)
{
if ( logger.isLoggable( MLevel.FINE ) )
logger.log( MLevel.FINE, "BasicResourcePool -- A resource couldn't be cleaned up on close()", e );
}
}
}
}
};
resourceDestroyer.start();
for (Iterator ii = acquireWaiters.iterator(); ii.hasNext(); )
((Thread) ii.next()).interrupt();
for (Iterator ii = otherWaiters.iterator(); ii.hasNext(); )
((Thread) ii.next()).interrupt();
if (factory != null)
factory.markBroken( this );
}
I also have same issue. Is it c3p0 or maybe I miss some configuration?! my c3p0 DataSource is created by Spring and has destroy-method="close".
@yasserzamani it's no misconfiguration. @bgedik has diagnosed the issue correctly. c3p0's philosophy is to do as much as it can asynchronously, and that is true of closing ancillary resources associated with DataSources as well. in c3p0-0.9.6, i may try to offer a means of synchronous close (but no promises). for now, resources do get cleaned up, but you may need to tolerate hot-restart false alarms.