1
0

1. Wrapped System.getProperties with doPrivileged.

2. Moved catch.  If System properties cannot be loaded,
    then don't abandon effort, but go on to loading
    properties file.


git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@138942 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Richard A. Sitze
2002-12-12 19:23:34 +00:00
parent 4e0ad3c8ff
commit b122313d94

View File

@@ -1,7 +1,7 @@
/* /*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/impl/SimpleLog.java,v 1.5 2002/10/19 17:19:05 rsitze Exp $ * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/impl/SimpleLog.java,v 1.6 2002/12/12 19:23:34 rsitze Exp $
* $Revision: 1.5 $ * $Revision: 1.6 $
* $Date: 2002/10/19 17:19:05 $ * $Date: 2002/12/12 19:23:34 $
* *
* ==================================================================== * ====================================================================
* *
@@ -65,6 +65,8 @@ package org.apache.commons.logging.impl;
import java.io.InputStream; import java.io.InputStream;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.security.AccessControlException; import java.security.AccessControlException;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
@@ -106,7 +108,7 @@ import org.apache.commons.logging.Log;
* @author Rod Waldhoff * @author Rod Waldhoff
* @author Robert Burrell Donkin * @author Robert Burrell Donkin
* *
* @version $Id: SimpleLog.java,v 1.5 2002/10/19 17:19:05 rsitze Exp $ * @version $Id: SimpleLog.java,v 1.6 2002/12/12 19:23:34 rsitze Exp $
*/ */
public class SimpleLog implements Log { public class SimpleLog implements Log {
@@ -160,13 +162,22 @@ public class SimpleLog implements Log {
try { try {
// add all system props that start with the specified prefix // add all system props that start with the specified prefix
Enumeration enum = System.getProperties().propertyNames(); Enumeration enum = (Enumeration)AccessController.doPrivileged(
new PrivilegedAction() {
public Object run() {
return System.getProperties().propertyNames();
}
});
while(enum.hasMoreElements()) { while(enum.hasMoreElements()) {
String name = (String)(enum.nextElement()); String name = (String)(enum.nextElement());
if(null != name && name.startsWith(systemPrefix)) { if(null != name && name.startsWith(systemPrefix)) {
simpleLogProps.setProperty(name,System.getProperty(name)); simpleLogProps.setProperty(name,System.getProperty(name));
} }
} }
}
catch (AccessControlException e) {
// ignore access control exceptions when trying to check system properties
}
// identify the class loader to attempt resource loading with // identify the class loader to attempt resource loading with
ClassLoader classLoader = null; ClassLoader classLoader = null;
@@ -223,10 +234,6 @@ public class SimpleLog implements Log {
systemPrefix + "dateformat","yyyy/MM/dd HH:mm:ss:SSS zzz")); systemPrefix + "dateformat","yyyy/MM/dd HH:mm:ss:SSS zzz"));
} }
} }
catch (AccessControlException e) {
// ignore access control exceptions when trying to check system properties
}
}
// ------------------------------------------------------------- Attributes // ------------------------------------------------------------- Attributes