Fix LOGGING-106 where JCL wouldn't start when run under a SecurityManager that refuses access to system properties.
Also use an AccessController so that a signed JCL will work in an unsigned app; note that there appears to be other places where we are missing AccessControllers too. git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@423654 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -316,8 +316,15 @@ public abstract class LogFactory {
|
||||
*/
|
||||
private static final Hashtable createFactoryStore() {
|
||||
Hashtable result = null;
|
||||
String storeImplementationClass
|
||||
= System.getProperty(HASHTABLE_IMPLEMENTATION_PROPERTY);
|
||||
String storeImplementationClass;
|
||||
try {
|
||||
storeImplementationClass = System.getProperty(HASHTABLE_IMPLEMENTATION_PROPERTY);
|
||||
} catch(SecurityException ex) {
|
||||
// Permissions don't allow this to be accessed. Default to the "modern"
|
||||
// weak hashtable implementation if it is available.
|
||||
storeImplementationClass = null;
|
||||
}
|
||||
|
||||
if (storeImplementationClass == null) {
|
||||
storeImplementationClass = WEAK_HASHTABLE_CLASSNAME;
|
||||
}
|
||||
@@ -1698,6 +1705,19 @@ public abstract class LogFactory {
|
||||
}
|
||||
}
|
||||
|
||||
// called from static class initialiser, ie when class is loaded
|
||||
private static void initClass() {
|
||||
// note: it's safe to call methods before initDiagnostics (though
|
||||
// diagnostic output gets discarded).
|
||||
thisClassLoader = getClassLoader(LogFactory.class);
|
||||
initDiagnostics();
|
||||
logClassLoaderEnvironment(LogFactory.class);
|
||||
factories = createFactoryStore();
|
||||
if (isDiagnosticsEnabled()) {
|
||||
logDiagnostic("BOOTSTRAP COMPLETED");
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Static initialiser block to perform initialisation at class load time.
|
||||
//
|
||||
@@ -1718,13 +1738,12 @@ public abstract class LogFactory {
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
static {
|
||||
// note: it's safe to call methods before initDiagnostics.
|
||||
thisClassLoader = getClassLoader(LogFactory.class);
|
||||
initDiagnostics();
|
||||
logClassLoaderEnvironment(LogFactory.class);
|
||||
factories = createFactoryStore();
|
||||
if (isDiagnosticsEnabled()) {
|
||||
logDiagnostic("BOOTSTRAP COMPLETED");
|
||||
}
|
||||
AccessController.doPrivileged(
|
||||
new PrivilegedAction() {
|
||||
public Object run() {
|
||||
initClass();
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user