You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by le...@apache.org on 2007/08/15 11:35:01 UTC
svn commit: r566076 - in
/harmony/enhanced/classlib/trunk/modules/logging/src:
main/java/java/util/logging/Logger.java
test/java/org/apache/harmony/logging/tests/java/util/logging/LoggerTest.java
test/resources/config/java/util/logging/logging.config
Author: leoli
Date: Wed Aug 15 02:35:00 2007
New Revision: 566076
URL: http://svn.apache.org/viewvc?view=rev&rev=566076
Log:
Apply patch for HARMONY-4594( [classlib][logging] Logger should read handlers property with comma or spaces seperation).
Modified:
harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Logger.java
harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LoggerTest.java
harmony/enhanced/classlib/trunk/modules/logging/src/test/resources/config/java/util/logging/logging.config
Modified: harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Logger.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Logger.java?view=diff&rev=566076&r1=566075&r2=566076
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Logger.java (original)
+++ harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Logger.java Wed Aug 15 02:35:00 2007
@@ -438,9 +438,12 @@
if (null == handlerStr) {
return;
}
- StringTokenizer st = new StringTokenizer(handlerStr, " "); //$NON-NLS-1$
- while (st.hasMoreTokens()) {
- String handlerName = st.nextToken();
+ String[] strs = handlerStr.split(",|\\s");
+ for (int i = 0; i < strs.length; i++) {
+ String handlerName = strs[i];
+ if (handlerName.equals("")){
+ continue;
+ }
Handler handler = (Handler) LogManager
.getInstanceByClass(handlerName);
handlers.add(handler);
Modified: harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LoggerTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LoggerTest.java?view=diff&rev=566076&r1=566075&r2=566076
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LoggerTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LoggerTest.java Wed Aug 15 02:35:00 2007
@@ -17,6 +17,8 @@
package org.apache.harmony.logging.tests.java.util.logging;
+import java.io.File;
+import java.io.FileInputStream;
import java.security.Permission;
import java.util.Locale;
import java.util.MissingResourceException;
@@ -50,6 +52,8 @@
private final static String VALID_RESOURCE_BUNDLE3 = "bundles/java/util/logging/res3";
private final static String INVALID_RESOURCE_BUNDLE = "impossible_not_existing";
+
+ private final static String LOGGING_CONFIG_FILE= "src/test/resources/config/java/util/logging/logging.config";
private final static String VALID_KEY = "LOGGERTEST";
@@ -3451,6 +3455,20 @@
} finally {
System.setSecurityManager(originalSecurityManager);
}
+ }
+
+ /*
+ * test initHandler
+ */
+ public void test_initHandler() throws Exception {
+ File logProps = new File(LOGGING_CONFIG_FILE);
+ LogManager lm = LogManager.getLogManager();
+ lm.readConfiguration(new FileInputStream(logProps));
+
+ Logger log = Logger.getLogger("");
+ // can log properly
+ Handler[] handlers = log.getHandlers();
+ assertEquals(2, handlers.length);
}
/*
Modified: harmony/enhanced/classlib/trunk/modules/logging/src/test/resources/config/java/util/logging/logging.config
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/logging/src/test/resources/config/java/util/logging/logging.config?view=diff&rev=566076&r1=566075&r2=566076
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/logging/src/test/resources/config/java/util/logging/logging.config (original)
+++ harmony/enhanced/classlib/trunk/modules/logging/src/test/resources/config/java/util/logging/logging.config Wed Aug 15 02:35:00 2007
@@ -1,3 +1,3 @@
-handlers=org.apache.harmony.logging.tests.java.util.logging.LogManagerTest$MockHandler java.util.logging.ConsoleHandler
+handlers=org.apache.harmony.logging.tests.java.util.logging.LogManagerTest$MockHandler , java.util.logging.ConsoleHandler
.level=ALL
org.apache.harmony.logging.tests.java.util.logging.LogManagerTest$MockHandler.level=OFF