mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +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;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
package sun.util.cldr;
|
||||
|
||||
import java.security.AccessController;
|
||||
import java.security.AccessControlException;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.text.spi.BreakIteratorProvider;
|
||||
import java.text.spi.CollatorProvider;
|
||||
|
@ -37,6 +38,7 @@ import java.util.Locale;
|
|||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.ServiceConfigurationError;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
@ -81,8 +83,11 @@ public class CLDRLocaleProviderAdapter extends JRELocaleProviderAdapter {
|
|||
return null;
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
// Catch any exception, and continue as if only CLDR's base locales exist.
|
||||
} catch (ServiceConfigurationError sce) {
|
||||
Throwable cause = sce.getCause();
|
||||
if (!(cause instanceof AccessControlException)) throw sce;
|
||||
}
|
||||
|
||||
nonBaseMetaInfo = nbmi;
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
package sun.util.locale.provider;
|
||||
|
||||
import java.security.AccessController;
|
||||
import java.security.AccessControlException;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.text.spi.BreakIteratorProvider;
|
||||
|
@ -40,6 +41,7 @@ import java.util.List;
|
|||
import java.util.Locale;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.ServiceConfigurationError;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
@ -476,8 +478,11 @@ public class JRELocaleProviderAdapter extends LocaleProviderAdapter implements R
|
|||
if (nonBaseTags != null) {
|
||||
supportedLocaleString += " " + nonBaseTags;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
// catch any exception, and ignore them as if non-EN locales do not exist.
|
||||
} catch (ServiceConfigurationError sce) {
|
||||
Throwable cause = sce.getCause();
|
||||
if (!(cause instanceof AccessControlException)) throw sce;
|
||||
}
|
||||
|
||||
return supportedLocaleString;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue