Skip to content

inventage/wildfly-managed-scheduled-executor-service-reproducer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Explanation

There exists a race condition in org.glassfish.enterprise.concurrent.internal.ManagedScheduledThreadPoolExecutor which is easily triggered by scheduling a task with ManagedScheduledExecutorService#scheduleAtFixedRate that occasionally takes longer than the interval at which the task is scheduled.

Example with 2 threads (th1, th2) in the thread pool:

  1. th1: runWorker -> getTask() : gets the task to execute
  2. th1: runWorker -> beforeExecute() : runs the setup context handles and saves the reset handles to the task
  3. th1: runWorker -> runAndReset() : runs the task (which takes longer than the scheduled interval) and re-adds it to the queue with a nextRunTime in the past
  4. th2: runWorker -> getTask() : gets the task to execute
  5. th2: runWorker -> beforeExecute() : runs the setup context handles and saves the reset handles to the task, overwriting the reset handles from th1
  6. th1: runWorker -> afterExecute() : executes the reset handles of the task, setting them to null on the task
  7. th2: runWorker -> runAndReset() : runs the task and re-adds it to the queue
  8. th2: runWorker -> afterExecute() : reset handles are null, no reset is performed

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages