Skip to content

Commit 96a3a88

Browse files
committed
8344993: [21u] [REDO] Backport JDK-8327501 and JDK-8328366 to JDK 21
Reviewed-by: sgehwolf
1 parent d383ba5 commit 96a3a88

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -981,9 +981,7 @@ public final ForkJoinWorkerThread newThread(ForkJoinPool pool) {
981981
boolean isCommon = (pool.workerNamePrefix == null);
982982
@SuppressWarnings("removal")
983983
SecurityManager sm = System.getSecurityManager();
984-
if (sm == null)
985-
return new ForkJoinWorkerThread(null, pool, true, false);
986-
else if (isCommon)
984+
if (sm != null && isCommon)
987985
return newCommonWithACC(pool);
988986
else
989987
return newRegularWithACC(pool);

test/jdk/java/util/concurrent/tck/ForkJoinPool9Test.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ public void testCommonPoolThreadContextClassLoader() throws Throwable {
7979
assertSame(ForkJoinPool.commonPool(), ForkJoinTask.getPool());
8080
Thread currentThread = Thread.currentThread();
8181

82+
ClassLoader preexistingContextClassLoader =
83+
currentThread.getContextClassLoader();
84+
8285
Stream.of(systemClassLoader, null).forEach(cl -> {
8386
if (randomBoolean())
8487
// should always be permitted, without effect
@@ -95,6 +98,11 @@ public void testCommonPoolThreadContextClassLoader() throws Throwable {
9598
() -> System.getProperty("foo"),
9699
() -> currentThread.setContextClassLoader(
97100
classLoaderDistinctFromSystemClassLoader));
101+
else {
102+
currentThread.setContextClassLoader(classLoaderDistinctFromSystemClassLoader);
103+
assertSame(currentThread.getContextClassLoader(), classLoaderDistinctFromSystemClassLoader);
104+
currentThread.setContextClassLoader(preexistingContextClassLoader);
105+
}
98106
// TODO ?
99107
// if (haveSecurityManager
100108
// && Thread.currentThread().getClass().getSimpleName()

0 commit comments

Comments
 (0)