Skip to content

Commit c3a4358

Browse files
authored
Merge pull request quarkusio#50635 from geoand/quarkusio#50617
Ensure that FJP threads can load resources in tests
2 parents 01ef2cc + 73d13a8 commit c3a4358

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

core/deployment/src/main/java/io/quarkus/runner/bootstrap/ForkJoinClassLoading.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,18 @@ public class ForkJoinClassLoading {
1313
/**
1414
* A yucky hack, basically attempt to make sure every thread in the common pool has
1515
* the correct CL.
16-
*
16+
* <p>
1717
* It's not perfect, but as this only affects test and dev mode and not production it is better
1818
* than nothing.
19-
*
19+
* <p>
2020
* Really we should just not use the common pool at all.
21+
* <p>
22+
* TODO: This no longer works in Java 25 because the `ForkJoinPool` now does
23+
* <a href=
24+
* "https://github.com/openjdk/jdk/blob/jdk-25%2B36/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java#L2085">
25+
* this</a>, which ends up calling <a href=
26+
* "https://github.com/openjdk/jdk/blob/jdk-25%2B36/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java#L280">this</a>.
27+
* We need to figure out how to deal with this
2128
*/
2229
public static void setForkJoinClassLoader(ClassLoader classLoader) {
2330
CountDownLatch allDone = new CountDownLatch(ForkJoinPool.getCommonPoolParallelism());

test-framework/junit5/src/main/java/io/quarkus/test/junit/launcher/CustomLauncherInterceptor.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ public void launcherDiscoveryStarted(LauncherDiscoveryRequest request) {
8787
if (!isProductionModeTests()) {
8888
initializeFacadeClassLoader();
8989
adjustContextClassLoader();
90+
91+
// we need to ensure that the Fork-Join pool will use our thread factory, otherwise the TCCL
92+
// of the threads could be wrong
93+
System.setProperty("java.util.concurrent.ForkJoinPool.common.threadFactory",
94+
"io.quarkus.bootstrap.forkjoin.QuarkusForkJoinWorkerThreadFactory");
9095
}
9196

9297
}

0 commit comments

Comments
 (0)