commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From skitch...@apache.org
Subject svn commit: r423654 - /jakarta/commons/proper/logging/trunk/src/java/org/apache/commons/logging/LogFactory.java
Date Wed, 19 Jul 2006 23:31:01 GMT
Author: skitching
Date: Wed Jul 19 16:31:00 2006
New Revision: 423654

URL: http://svn.apache.org/viewvc?rev=423654&view=rev
Log:
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.

Modified:
    jakarta/commons/proper/logging/trunk/src/java/org/apache/commons/logging/LogFactory.java

Modified: jakarta/commons/proper/logging/trunk/src/java/org/apache/commons/logging/LogFactory.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/logging/trunk/src/java/org/apache/commons/logging/LogFactory.java?rev=423654&r1=423653&r2=423654&view=diff
==============================================================================
--- jakarta/commons/proper/logging/trunk/src/java/org/apache/commons/logging/LogFactory.java
(original)
+++ jakarta/commons/proper/logging/trunk/src/java/org/apache/commons/logging/LogFactory.java
Wed Jul 19 16:31:00 2006
@@ -316,8 +316,15 @@
      */
     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 @@
         }
     }
 
+    // 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 @@
     // ----------------------------------------------------------------------
 
     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;
+                }
+            });
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message