mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 14:24:46 +02:00
8189264: (sl) ServiceLoader does not wrap Errors thrown by provider classes when running with a security manager
Reviewed-by: mchung
This commit is contained in:
parent
cae8353ec8
commit
e4bea042c5
5 changed files with 92 additions and 11 deletions
|
@ -747,8 +747,10 @@ public final class ServiceLoader<S>
|
|||
// invoke factory method with permissions restricted by acc
|
||||
try {
|
||||
result = AccessController.doPrivileged(pa, acc);
|
||||
} catch (PrivilegedActionException pae) {
|
||||
exc = pae.getCause();
|
||||
} catch (Throwable x) {
|
||||
if (x instanceof PrivilegedActionException)
|
||||
x = x.getCause();
|
||||
exc = x;
|
||||
}
|
||||
}
|
||||
if (exc != null) {
|
||||
|
@ -788,8 +790,10 @@ public final class ServiceLoader<S>
|
|||
// invoke constructor with permissions restricted by acc
|
||||
try {
|
||||
p = AccessController.doPrivileged(pa, acc);
|
||||
} catch (PrivilegedActionException pae) {
|
||||
exc = pae.getCause();
|
||||
} catch (Throwable x) {
|
||||
if (x instanceof PrivilegedActionException)
|
||||
x = x.getCause();
|
||||
exc = x;
|
||||
}
|
||||
}
|
||||
if (exc != null) {
|
||||
|
@ -852,8 +856,9 @@ public final class ServiceLoader<S>
|
|||
PrivilegedExceptionAction<Class<?>> pa = () -> Class.forName(module, cn);
|
||||
try {
|
||||
clazz = AccessController.doPrivileged(pa);
|
||||
} catch (PrivilegedActionException pae) {
|
||||
Throwable x = pae.getCause();
|
||||
} catch (Throwable x) {
|
||||
if (x instanceof PrivilegedActionException)
|
||||
x = x.getCause();
|
||||
fail(service, "Unable to load " + cn, x);
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue