Uploaded image for project: 'Commons Pool'
  1. Commons Pool
  2. POOL-337

EvictionTimer does not remove cancelled tasks from the executor, leading to an IllegalStateException when the evictor attempts to evict

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.5.0
    • None
    • None

    Description

      EvictionTimer does not remove cancelled tasks from the executor, leading to an IllegalStateException when the evictor attempts to evict.

       

      EvictionTimer::schedule() adds eviction tasks to the executor, but the cancel does not remove it. This is asymmetric and leads to the following exception:

      java.lang.IllegalStateException: Pool not open
      	at org.apache.commons.pool2.impl.BaseGenericObjectPool.assertOpen(BaseGenericObjectPool.java:713)
      	at org.apache.commons.pool2.impl.GenericObjectPool.evict(GenericObjectPool.java:721)
      	at org.apache.commons.pool2.impl.BaseGenericObjectPool$Evictor.run(BaseGenericObjectPool.java:1077)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
      	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
      	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at java.lang.Thread.run(Thread.java:748)

      I think the cancel would need to remember the future which returned from executor::scheduleWithFixedDelay() in schedule() and then do something like this (see EvictionTimer.java compared to original EvictionTimer.java.original-from-2.5.0.java )

      if (futures.containsKey(task)) {
          futures.remove(task).cancel(false);
          executor.purge();
      }

      Attachments

        1. EvictionTimer.java.original-from-2.5.0.java
          5 kB
          Reinald Verheij
        2. EvictionTimer.java
          7 kB
          Reinald Verheij

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            rverheij Reinald Verheij
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment