8328366: Thread.setContextClassloader from thread in FJP commonPool task no longer works after JDK-8327501
Reviewed-by: mchung, alanb
This commit is contained in:
parent
4276d5c004
commit
28216aa971
@ -1140,12 +1140,7 @@ public class ForkJoinPool extends AbstractExecutorService {
|
|||||||
boolean isCommon = (pool.workerNamePrefix == null);
|
boolean isCommon = (pool.workerNamePrefix == null);
|
||||||
@SuppressWarnings("removal")
|
@SuppressWarnings("removal")
|
||||||
SecurityManager sm = System.getSecurityManager();
|
SecurityManager sm = System.getSecurityManager();
|
||||||
if (sm == null) {
|
if (sm != null && isCommon)
|
||||||
if (isCommon)
|
|
||||||
return new ForkJoinWorkerThread.InnocuousForkJoinWorkerThread(pool);
|
|
||||||
else
|
|
||||||
return new ForkJoinWorkerThread(null, pool, true, false);
|
|
||||||
} else if (isCommon)
|
|
||||||
return newCommonWithACC(pool);
|
return newCommonWithACC(pool);
|
||||||
else
|
else
|
||||||
return newRegularWithACC(pool);
|
return newRegularWithACC(pool);
|
||||||
|
@ -79,6 +79,9 @@ public class ForkJoinPool9Test extends JSR166TestCase {
|
|||||||
assertSame(ForkJoinPool.commonPool(), ForkJoinTask.getPool());
|
assertSame(ForkJoinPool.commonPool(), ForkJoinTask.getPool());
|
||||||
Thread currentThread = Thread.currentThread();
|
Thread currentThread = Thread.currentThread();
|
||||||
|
|
||||||
|
ClassLoader preexistingContextClassLoader =
|
||||||
|
currentThread.getContextClassLoader();
|
||||||
|
|
||||||
Stream.of(systemClassLoader, null).forEach(cl -> {
|
Stream.of(systemClassLoader, null).forEach(cl -> {
|
||||||
if (randomBoolean())
|
if (randomBoolean())
|
||||||
// should always be permitted, without effect
|
// should always be permitted, without effect
|
||||||
@ -95,6 +98,11 @@ public class ForkJoinPool9Test extends JSR166TestCase {
|
|||||||
() -> System.getProperty("foo"),
|
() -> System.getProperty("foo"),
|
||||||
() -> currentThread.setContextClassLoader(
|
() -> currentThread.setContextClassLoader(
|
||||||
classLoaderDistinctFromSystemClassLoader));
|
classLoaderDistinctFromSystemClassLoader));
|
||||||
|
else {
|
||||||
|
currentThread.setContextClassLoader(classLoaderDistinctFromSystemClassLoader);
|
||||||
|
assertSame(currentThread.getContextClassLoader(), classLoaderDistinctFromSystemClassLoader);
|
||||||
|
currentThread.setContextClassLoader(preexistingContextClassLoader);
|
||||||
|
}
|
||||||
// TODO ?
|
// TODO ?
|
||||||
// if (haveSecurityManager
|
// if (haveSecurityManager
|
||||||
// && Thread.currentThread().getClass().getSimpleName()
|
// && Thread.currentThread().getClass().getSimpleName()
|
||||||
|
Loading…
Reference in New Issue
Block a user