Return-Path: Delivered-To: apmail-incubator-harmony-commits-archive@www.apache.org Received: (qmail 18029 invoked from network); 5 Sep 2006 08:18:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 5 Sep 2006 08:18:28 -0000 Received: (qmail 41230 invoked by uid 500); 5 Sep 2006 08:18:28 -0000 Delivered-To: apmail-incubator-harmony-commits-archive@incubator.apache.org Received: (qmail 41205 invoked by uid 500); 5 Sep 2006 08:18:28 -0000 Mailing-List: contact harmony-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-commits@incubator.apache.org Received: (qmail 41194 invoked by uid 99); 5 Sep 2006 08:18:28 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Sep 2006 01:18:28 -0700 X-ASF-Spam-Status: No, hits=-8.6 required=10.0 tests=ALL_TRUSTED,INFO_TLD,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Sep 2006 01:18:27 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 61B401A981A; Tue, 5 Sep 2006 01:18:07 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: harmony-commits@incubator.apache.org From: pyang@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20060905081807.61B401A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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 loggers; - private Logger root; - // the configuration properties private Properties props; @@ -178,7 +176,7 @@ // init LogManager singleton instance AccessController.doPrivileged(new PrivilegedAction() { 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 * LogManager instance, which can be get by * LogManager.getLogManager(. 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); }