Wrapping the call to CompletableFuture#allOf won't help as this is simply collecting the results of the asynchronous calls. The asynchronous calls themselves are not executed in the context of Sudo this way.
If you want to do that, you need to wrap the Runnable in Sudo like this:
IvyAsyncExecutor.create().run(() -> {
Sudo.call(() -> {...});
});
or even wrap the entire thing in Sudo like this:
Sudo.call(() -> {
IvyAsyncExecutor.create().run(() -> {...});
});
You can try that if you want. Although, I don't see how that would solve the issue.
I think to properly analyze the issue, we need to take a closer look at your project to understand the chain of execution and its context. I noticed that you (or one of your colleagues) created a support ticket in the past about a similar issue and managed to resolve it yourself via a workaround. We didn't receive a lot of information about your project back then but did at least improve the logging mechanism around the IvyAsyncExecutor.
Can you open a support ticket and provide the following artifacts in addition to the usual if possible?
- A link to this post.
- A minimal example project where the issue occurs.
- The actual project where the issue occurs.
P.S. In the past, I provided a patch to your company with a prototype of the IvyAsyncExecutor. Just to verify, can you double-check that this patch is no longer present on the engine where the issue occurs? See if there is a directory named patches present in the root directory of the engine and whether it contains a JAR named something like ch.ivyteam.ivy.request or anything else that might contain that prototype.