I removed tests of context switch, which tested, that the context capture happened during jndi lookup. The test later setup number 22 and the test checks, if asynchronous method (running via scheduler) returns 0.
The code:
ManagedExecutorDefinitionFullTests.testScheduledAsynchIgnoresMaxAsync() {
...
IntContext.set(22); //Context should be cleared
CompletableFuture<Integer> future = reqBean.scheduledEvery3Seconds(1, counter);
...
assertEquals(Integer.valueOf(0), future.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS),
"ManagedScheduledExecutorService with maxAsync=4 must be able to run scheduled async methods concurrently.");
reqBean.scheduledEvery3Seconds runs only once and returns IntContext: future.complete(IntContext.get())
There is no explicit setup of the IntContext value to test.
This test checks just the context switch, not asynch methods running concurrently as it says in the message. Although it is called schedule, it runs only once.
I removed tests of context switch, which tested, that the context capture happened during jndi lookup. The test later setup number 22 and the test checks, if asynchronous method (running via scheduler) returns 0.
The code:
reqBean.scheduledEvery3Seconds
runs only once and returnsIntContext
:future.complete(IntContext.get())
The discussion, if the context capture should happen on JNDI lookup or when the thread is created, is still open: https://github.com/jakartaee/concurrency/issues/253