Code not being executed in Play Framework scheduled job

Hello !

I use Play Framework 2.6.20 for a website. It schedules a task as follow in a dedicated Module:

@Singleton
public class MyJob implements Runnable{
    @Inject
    public MyJob(RestHighLevelClientProvider clientProvider, ActorSystem actorSystem, MyConfig config, ExecutionContext context) {
      [...]

      if (config.isEnabled()) {
        this.actorSystem.scheduler().schedule(
                Duration.ofSeconds(10), // initialDelay
                Duration.ofSeconds(config.getPollInterval()), // interval
                this,
                context
        );
    }
}

The run is as follow:

@Override
public void run() {
    Logger.info("Inspection starting");
        this.someStuffWithCompletableFuture().
                thenCompose(/* DO SOMETHING WITH SOME LOGS */).
                thenCompose(/* DO SOMETHING WITH SOME LOGS */).
                thenAccept(a -> Logger.info("Inspection finished"));
}

With this code, I have the expected behavior on our QA environments and locally, but it fails on preproduction. I see “Inspection starting” but never get the logs inside the intermediate completable futures, nor “Inspection finished”.

I tried making it synchronous:

@Override
public void run() {
    Logger.info("Inspection starting");
    try {
        this.someStuffWithCompletableFuture().
                thenCompose(/* DO SOMETHING */).
                thenCompose(/* DO SOMETHING */).
                thenAccept(a -> Logger.info("Inspection finished")).
                toCompletableFuture().
                get();
    } catch (InterruptedException | ExecutionException e) {
        Logger.info("Inspection was interupted");
    }
}

And this time, I see “Inspection starting” followed by “Inspection was interupted”.

Would you have some idea about why the thread is stopped ? How can I do it properly with Completable Futures ?

Thanks