Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-30375

[GSS](8.1.z) WFLY-20727 - ManagedScheduledExecutorService unexpectedly executes tasks multiple times

XMLWordPrintable

    • False
    • Hide

      None

      Show
      None
    • False
    • Known Issue

      A ManagedScheduledExecutorService unexpectedly executes tasks multiple times.

      standalone.xml:

      <managed-scheduled-executor-service name="default" jndi-name="java:jboss/ee/concurrency/scheduler/default" context-service="default" hung-task-termination-period="0" hung-task-threshold="60000" keepalive-time="3000"/>
      

      Reproducer app:

      import jakarta.annotation.Resource;
      import jakarta.enterprise.concurrent.CronTrigger;
      import jakarta.enterprise.concurrent.LastExecution;
      import jakarta.enterprise.concurrent.ManagedScheduledExecutorService;
      import jakarta.enterprise.context.ApplicationScoped;
      import jakarta.enterprise.event.Observes;
      import jakarta.enterprise.event.Startup;
      
      import java.time.ZoneId;
      import java.time.ZonedDateTime;
      
      @ApplicationScoped
      public class DummyBean {
      
          @Resource(mappedName = "java:jboss/ee/concurrency/scheduler/default")
          ManagedScheduledExecutorService executorService;
      
          public DummyBean() {
          }
      
          private void onStart(@Observes Startup startup) {
              System.out.println("Start");
              executorService.schedule(() -> something(),
                                       new CronTrigger(ZoneId.systemDefault()) {
                                           @Override
                                           public ZonedDateTime getNextRunTime(LastExecution lastExecutionInfo, ZonedDateTime taskScheduledTime) {
                                               ZonedDateTime nextRunTime = super.getNextRunTime(lastExecutionInfo, taskScheduledTime);
                                               System.out.println("ZonedDateTime getNextRunTime " + nextRunTime);
                                               return nextRunTime;
                                           }
                                       }.hours("*").minutes("*").seconds("*/10"));
          }
      
          private void something() {
              System.out.println("something");
          }
      
      }
      

      The following log is printed.

      Please notice the "duplicate" executions at 11:33:50.

      Apparently the internal compution of the next execution sometimes returns the same value as for the prevoius execution (see log above).

              rhn-cservice-bbaranow Bartosz Baranowski
              rhn-support-jbaesner Joerg Baesner
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: