Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8144799

Executors.newSingleThreadExecutor().submit(runnable) throw RejectedExeception

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version "1.8.0_51"
      Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
      Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)

      A DESCRIPTION OF THE PROBLEM :
      When spring framework init a bean object, it will invoke afterPropertiesSet() method.
      My code like this:
      public void afterPropertiesSet()
      {
      Executors.newSingleThreadExecutor().submit(new Runnable()
      {
      @Override
      public void run()
      {
      Thread.currentThread().setName("StartUp-1");
      try
      {
      .....
      }
      catch (Exception e)
      {
      logger.error("", e);
      }
      }

      });
      }
      but there throw a RejectedExeception:
      Caused by: java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.FutureTask@694abf75 rejected from java.util.concurrent.ThreadPoolExecutor@15e7578d[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0]
      at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2047)
      at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:823)
      at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1369)
      at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:112)
      at java.util.concurrent.Executors$DelegatedExecutorService.submit(Executors.java:678)
      at demo.MyService.afterPropertiesSet(TopoService.java:248)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
      ... 18 more


      REPRODUCIBILITY :
      This bug can be reproduced rarely.

            psonal Pallavi Sonal (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: