-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
36.0.1.Final
-
None
-
---
-
---
We noticed that the undeployment of a WAR with a scheduled timer does not stop the timer (the timer still runs after undeplyoment) and after a new deplyoment the timer generally runs twice and so on.
import jakarta.annotation.Resource; import jakarta.enterprise.concurrent.CronTrigger; import jakarta.enterprise.concurrent.ManagedScheduledExecutorService; import jakarta.enterprise.context.ApplicationScoped; import jakarta.enterprise.event.Observes; import jakarta.enterprise.event.Startup; import java.time.ZoneId; @ApplicationScoped public class DummyBean { @Resource(mappedName = "java:jboss/ee/concurrency/scheduler/default") ManagedScheduledExecutorService executorService; public DummyBean() { } private void onStart(@Observes Startup startup) { executorService.schedule(() -> something(), new CronTrigger(ZoneId.systemDefault()).hours("*").minutes("*").seconds("*/10")); } private void something() { System.out.println("something " + System.currentTimeMillis()); } }
This apparently is a spec violation: https://jakarta.ee/specifications/concurrency/3.1/jakarta-concurrency-spec-3.1#jakarta-ee-product-provider-requirements-3
3. All tasks submitted to an executor must not run if task’s component is not started.