|
|
|
@ -30,10 +30,10 @@ import org.slf4j.LoggerFactory;
|
|
|
|
|
*
|
|
|
|
|
* @author Brett Wooldridge
|
|
|
|
|
*/
|
|
|
|
|
class ProxyLeakTask implements Runnable
|
|
|
|
|
class LeakTask implements Runnable
|
|
|
|
|
{
|
|
|
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(ProxyLeakTask.class);
|
|
|
|
|
private static final ProxyLeakTask NO_LEAK;
|
|
|
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(LeakTask.class);
|
|
|
|
|
private static final LeakTask NO_LEAK;
|
|
|
|
|
|
|
|
|
|
private ScheduledExecutorService executorService;
|
|
|
|
|
private long leakDetectionThreshold;
|
|
|
|
@ -43,32 +43,32 @@ class ProxyLeakTask implements Runnable
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|
{
|
|
|
|
|
NO_LEAK = new ProxyLeakTask() {
|
|
|
|
|
NO_LEAK = new LeakTask() {
|
|
|
|
|
@Override
|
|
|
|
|
public void cancel() {}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ProxyLeakTask(final long leakDetectionThreshold, final ScheduledExecutorService executorService)
|
|
|
|
|
LeakTask(final long leakDetectionThreshold, final ScheduledExecutorService executorService)
|
|
|
|
|
{
|
|
|
|
|
this.executorService = executorService;
|
|
|
|
|
this.leakDetectionThreshold = leakDetectionThreshold;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ProxyLeakTask(final ProxyLeakTask parent, final PoolEntry poolEntry)
|
|
|
|
|
private LeakTask(final LeakTask parent, final PoolEntry poolEntry)
|
|
|
|
|
{
|
|
|
|
|
this.exception = new Exception("Apparent connection leak detected");
|
|
|
|
|
this.connectionName = poolEntry.connection.toString();
|
|
|
|
|
scheduledFuture = parent.executorService.schedule(this, parent.leakDetectionThreshold, MILLISECONDS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ProxyLeakTask()
|
|
|
|
|
private LeakTask()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ProxyLeakTask start(final PoolEntry bagEntry)
|
|
|
|
|
LeakTask start(final PoolEntry bagEntry)
|
|
|
|
|
{
|
|
|
|
|
return (leakDetectionThreshold == 0) ? NO_LEAK : new ProxyLeakTask(this, bagEntry);
|
|
|
|
|
return (leakDetectionThreshold == 0) ? NO_LEAK : new LeakTask(this, bagEntry);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void updateLeakDetectionThreshold(final long leakDetectionThreshold)
|