Skip to content

Commit

Permalink
fix managed thread factory tests - context is saved before execution,…
Browse files Browse the repository at this point in the history
… not jndi lookup
  • Loading branch information
aubi authored and Petr Aubrecht committed May 12, 2022
1 parent c891da3 commit 761ae6d
Showing 1 changed file with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,8 @@ public void testParallelStreamBackedByManagedThreadFactory() throws Throwable {

ManagedThreadFactory threadFactory = InitialContext.doLookup("java:app/concurrent/ThreadFactoryA");

IntContext.set(2000);
StringContext.set("testParallelStreamBackedByManagedThreadFactory-2");

fj = new ForkJoinPool(4, threadFactory, null, false);

IntContext.set(3000);
StringContext.set("testParallelStreamBackedByManagedThreadFactory-3");

ForkJoinTask<Optional<Integer>> task = fj.submit(() -> {
return Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9)
.parallelStream()
Expand All @@ -222,6 +216,9 @@ public void testParallelStreamBackedByManagedThreadFactory() throws Throwable {
.reduce(Integer::sum);
});

IntContext.set(3000);
StringContext.set("testParallelStreamBackedByManagedThreadFactory-3");

Optional<Integer> result = task.join();
assertEquals(result.get(), Integer.valueOf(9180),
"Third-party context type IntContext must propagated to ForkJoin threads " +
Expand Down

0 comments on commit 761ae6d

Please sign in to comment.