Use abort rather than close to destroy abandoned connections
Create and use a singleton.
@@ -100,7 +100,7 @@ public class PoolableConnectionFactory implements PooledObjectFactory<PoolableCo
private Integer defaultQueryTimeoutSeconds;
- private final ExecutorService executor = Executors.newFixedThreadPool(3, new AbortThreadFactory());
+ private final ExecutorService executor = Executors.newFixedThreadPool(3, AbortThreadFactory.INSTANCE);
/**
* Creates a new {@code PoolableConnectionFactory}.
@@ -696,6 +696,8 @@ public class PoolableConnectionFactory implements PooledObjectFactory<PoolableCo
*/
private static class AbortThreadFactory implements ThreadFactory {
+ private static final AbortThreadFactory INSTANCE = new AbortThreadFactory();
+
@Override
public Thread newThread(final Runnable runnable) {
final Thread thread = new Thread(null, runnable, "commons-dbcp-abort-thread");
