psteitz commented on a change in pull request #32:
URL: https://github.com/apache/commons-pool/pull/32#discussion_r458466504
##########
File path: src/main/java/org/apache/commons/pool2/impl/EvictionTimer.java
##########
@@ -129,4 +167,45 @@ public Thread newThread(final Runnable runnable) {
return thread;
}
}
+
+ /**
+ * Task that removes references to abandoned tasks and shuts
+ * down the executor if there are no live tasks left.
+ */
+ private static class Reaper implements Runnable {
+ @Override
+ public void run() {
+ synchronized (EvictionTimer.class) {
+ for (Entry<WeakReference<Runnable>, WeakRunner> entry :
taskMap.entrySet()) {
+ if (entry.getKey().get() == null) {
+ executor.remove(entry.getValue());
+ taskMap.remove(entry.getKey());
+ }
+ }
Review comment:
Interesting observation. I left it in after addressing your comment
below because dead references (and empty executors) may hang around longer if
we wait until they run to kill them.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]