Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-10363

LazyInitializingExecutorService is not thread-safe

    Details

      Description

      LazyInitializingExecutorService.shutdown() is not synchronized, so it may miss the executor created on another thread.

      Normally the long time between the first use and stop is long enough for this to be a non-issue, but it does cause random thread leaks in PersistenceManagerTest:

      17:57:06,421 DEBUG (testng-PersistenceManagerTest:[]) [DefaultCacheManager] Started cache manager PersistenceManagerTest-NodeB on null
      17:57:06,423 INFO  (testng-PersistenceManagerTest:[]) [TestSuiteProgress] Test starting: org.infinispan.persistence.PersistenceManagerTest.testProcessAfterStop
      17:57:06,446 INFO  (testng-PersistenceManagerTest:[]) [TestSuiteProgress] Test succeeded: org.infinispan.persistence.PersistenceManagerTest.testProcessAfterStop
      17:57:06,447 DEBUG (testng-PersistenceManagerTest:[]) [DefaultCacheManager] Stopped cache manager PersistenceManagerTest-NodeB
      17:58:38,062 WARN  (main:[]) [ThreadLeakChecker] Possible leaked thread:
      "async-thread-PersistenceManagerTest-NodeB-p54399-t1" daemon prio=5 tid=0x2ab4c nid=NA waiting
         java.lang.Thread.State: WAITING
      	at java.base@11.0.3/jdk.internal.misc.Unsafe.park(Native Method)
      	at java.base@11.0.3/java.util.concurrent.locks.LockSupport.park(LockSupport.java:194)
      	at java.base@11.0.3/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2081)
      	at java.base@11.0.3/java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:433)
      	at java.base@11.0.3/java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1054)
      	at java.base@11.0.3/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1114)
      	at java.base@11.0.3/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
      	at java.base@11.0.3/java.lang.Thread.run(Thread.java:834)
      

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                dan.berindei Dan Berindei
                Reporter:
                dan.berindei Dan Berindei
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: