The Jetty scheduler participates in the Jetty component tree / lifecycle.
If it exists in a component that itself is being stopped (even temporarily), then the scheduler will shutdown.
Pointing to a specific line of code isn't really possible, as it's more like if the condition at a high level needs to stop, stop that component (which stops managed components under it which could be a scheduler), until the component is needed again and restarted.
If you use the Jetty Scheduler.schedule() during this state, then nothing happens, there's no ScheduledExecutorService to use, your attempt to schedule results in an empty Task instance that cannot be canceled. (literally a no-op Task per javadoc)
Again, just use the `java.util.ScheduledExecutorService` directly.
Bonus of doing that is you can use a more appropriate scheduling technique for your "runs every 2 seconds" use case, instead of rescheduling after every execution.
Plus you can control the lifecycle of it yourself.
And you can interrogate the state of the `ScheduledExecutorService` to find out the queue/task details.
See:
- scheduleAtFixedRate(Runnable,long,long,TimeUnit) - https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/concurrent/ScheduledExecutorService.html#scheduleAtFixedRate(java.lang.Runnable,long,long,java.util.concurrent.TimeUnit)
- scheduleWithFixedDelay(Runnable,long,long,TimeUnit) - https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/concurrent/ScheduledExecutorService.html#scheduleWithFixedDelay(java.lang.Runnable,long,long,java.util.concurrent.TimeUnit)
- Joakim