-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
36.0.1.Final
-
None
-
---
-
---
Future executions in a ManagedScheduledExecutorService are not executed anymore if one execution has been terminated by the hung task feature.
@ApplicationScoped public class DummyBean { private static final Logger LOGGER = LoggerFactory.getLogger(DummyBean.class); @Resource(mappedName = "java:jboss/ee/concurrency/scheduler/default") ManagedScheduledExecutorService executorService; public DummyBean() { } private void onStart(@Observes Startup startup) { System.out.println("Start"); executorService.schedule(() -> runSecured(this::something), new CronTrigger(ZoneId.systemDefault()).hours("*").minutes("*/1")); } private void something() { try { System.out.println("something before"); Thread.sleep(20000); System.out.println("something after"); } catch (InterruptedException e) { throw new RuntimeException(e); } } private void runSecured(Runnable runnable) { try { runnable.run(); } catch (Exception e) { LOGGER.error(e.getMessage(), e); } } }
with a smaller hung task threshold (e.g. 100):
<managed-scheduled-executor-services> <managed-scheduled-executor-service name="default" jndi-name="java:jboss/ee/concurrency/scheduler/default" context-service="default" hung-task-termination-period="10" hung-task-threshold="100" keepalive-time="3000"/> </managed-scheduled-executor-services>
We maybe wrongly assumed that only the current execution is cancelled but also all planned executions in the future are not executed anymore.
This does not happen with a SES from the JDK itself:
import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; ScheduledExecutorService ses = Executors.newScheduledThreadPool(10); ses.scheduleAtFixedRate(new Runnable() { @Override void run() { System.out.println("xxxx") Thread.currentThread().interrupt(); } }, 3, 3, TimeUnit.SECONDS);