harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r440292 - in /incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging: FileHandler.java LogManager.java
Date Tue, 05 Sep 2006 08:18:07 GMT
Author: pyang
Date: Tue Sep  5 01:18:06 2006
New Revision: 440292

URL: http://svn.apache.org/viewvc?view=rev&rev=440292
Log:
Fix some bugs of logging classes, including resource release, exception handling, etc.

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/FileHandler.java
    incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/LogManager.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/FileHandler.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/FileHandler.java?view=diff&rev=440292&r1=440291&r2=440292
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/FileHandler.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/FileHandler.java
Tue Sep  5 01:18:06 2006
@@ -215,13 +215,8 @@
                         files[i - 1].renameTo(files[i]);
                     }
                 }
-                try {
-                    fileStream = new FileOutputStream(fileName, append);
-                    channel = fileStream.getChannel();
-                } catch(FileNotFoundException e){
-                    //invalid path name, throw exception
-                    throw e;
-                }
+                fileStream = new FileOutputStream(fileName, append);
+                channel = fileStream.getChannel();
                 /*
                  * if lock is unsupported and IOException thrown, just let the
                  * IOException throws out and exit otherwise it will go into an
@@ -229,6 +224,11 @@
                  */
                 lock = channel.tryLock();
                 if (null == lock) {
+                    try{
+                        fileStream.close();
+                    }catch(Exception e){
+                        //ignore
+                    }
                     continue;
                 }
 				allLocks.put(fileName, lock);

Modified: incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/LogManager.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/LogManager.java?view=diff&rev=440292&r1=440291&r2=440292
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/LogManager.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/LogManager.java
Tue Sep  5 01:18:06 2006
@@ -160,8 +160,6 @@
      */
     private Hashtable<String, Logger> loggers;
 
-    private Logger root;
-
     // the configuration properties
     private Properties props;
 
@@ -178,7 +176,7 @@
 		// init LogManager singleton instance
 		AccessController.doPrivileged(new PrivilegedAction<Object>() {
 			public Object run() {
-				String className = getSystemProperty("java.util.logging.manager"); //$NON-NLS-1$
+				String className = System.getProperty("java.util.logging.manager"); //$NON-NLS-1$
 				if (null != className) {
 					manager = (LogManager) getInstanceByClass(className);
 				}
@@ -194,8 +192,9 @@
 				}
 
 				// if global logger has been initialized, set root as its parent
-				if (null != Logger.global) {
-					Logger.global.setParent(manager.root);
+                Logger root = manager.getLogger("");
+				if (null != Logger.global && null != root) {
+					Logger.global.setParent(root);
 				}
 				return null;
 			}
@@ -203,7 +202,6 @@
 	}
 
     /**
-     * 
      * Default constructor. This is not public because there should be only one
      * <code>LogManager</code> instance, which can be get by
      * <code>LogManager.getLogManager(</code>. This is protected so that
@@ -282,9 +280,6 @@
         }
         addToFamilyTree(logger, name);
         loggers.put(name, logger);
-        if (name.length() == 0) {
-            root = logger;
-        }
 
         setLoggerLevel(logger, name, false);
         logger.manager = this;
@@ -319,8 +314,7 @@
                 break;
             }
         }
-        if (parent == null && parent != root) {
-            parent = root;
+        if (parent == null && null != (parent = loggers.get(""))) {
             logger.internalSetParent(parent);
         }
 
@@ -406,11 +400,6 @@
         });
     }
 
-    // get system property
-    static String getSystemProperty(final String key) {
-        return System.getProperty(key);
-    }
-
     // use SystemClassLoader to load class from system classpath
     static Object getInstanceByClass(final String className) {
         try {
@@ -430,7 +419,7 @@
         boolean needInit = true;
 
         // check config class
-        String configClassName = getSystemProperty("java.util.logging.config.class"); //$NON-NLS-1$
+        String configClassName = System.getProperty("java.util.logging.config.class"); //$NON-NLS-1$
         if (null != configClassName) {
             if (null == getInstanceByClass(configClassName)) {
                 throw new RuntimeException("Cannot instantiate " //$NON-NLS-1$
@@ -440,7 +429,7 @@
         }
         // if config class failed, check config file
         if (needInit) {
-            String configFile = getSystemProperty("java.util.logging.config.file"); //$NON-NLS-1$
+            String configFile = System.getProperty("java.util.logging.config.file"); //$NON-NLS-1$
             if (null == configFile) {
                 // if cannot find configFile, use default logging.properties
                 configFile = new StringBuilder().append(
@@ -561,6 +550,7 @@
                 l.handlers = null;
             }
         }
+        Logger root = loggers.get("");
         if (null != root) {
             root.setLevel(Level.INFO);
         }



Mime
View raw message