JDK-6949710 : the GC'able nature of Logging objects needs to be made brutally clear
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util.logging
  • Affected Version: 6u18,6u20,7
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic,solaris,solaris_2.5.1
  • CPU: generic,x86,sparc
  • Submitted: 2010-05-05
  • Updated: 2011-04-19
  • Resolved: 2011-04-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7 Other
6u23Fixed 7 b114Fixed OpenJDK6Fixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Description
The following bug fix has made Logger objects GC'able:

    6274920 4/2 JDK logger holds strong reference to
                java.util.logging.Logger instances

Prior to the fix for 6274920, Logger objects were never GC'able
which was in direct violation of the spec for Logging.

In the JavaDoc for Logger.getLogger():

http://java.sun.com/javase/6/docs/api/java/util/logging/Logger.html#getLogger(java.lang.String)

it talks about how the Logger is created if it doesn't exist or an
existing Logger by the same name is returned. The following sentence
in the description is key to this issue:

    It will be registered in the LogManager global namespace. 

Jumping into the LogManager JavaDoc, the addLogger() function
is how a Logger is registered:

http://java.sun.com/javase/6/docs/api/java/util/logging/LogManager.html#addLogger(java.util.logging.Logger)

The following sentences are key:

    The application should retain its own reference to the Logger object
    to avoid it being garbage collected. The LogManager may only retain
    a weak reference.
The following bug:

    6947908 3/3 JAVA Logging interface is not threadsafe since 1.6.0_18

reveals the need to update the JavaDoc for Logger.getLogger.
The following bug:

    6921073 3/2 Most of the CTS tests fail against glassfish v3u1 b01 using
                jdk 1.6.0_18-b07

reveals the need to update the JavaDoc for LogManager.getLoggerNames()
and LogManager.getLogger(name) to clarify the GC'able nature of
Logger objects.

Comments
EVALUATION http://hg.openjdk.java.net/jdk7/tl/jdk/rev/4927d1319b2f
22-09-2010

SUGGESTED FIX See 6949710-webrev-cr1-openjdk6.tgz for the OpenJDK6 version of this fix. See 6949710-webrev-cr1-openjdk7.tgz for the OpenJDK7 version of this fix.
22-09-2010

EVALUATION The description section identifies the methods that need JavaDoc changes.
21-09-2010

SUGGESTED FIX See 6949710-webrev-cr0.tgz for the proposed JavaDoc changes sent out for code review round 0. This version is relative to JDK6_23.
21-09-2010

SUGGESTED FIX See 6949710-webrev-cr1.tgz for the proposed JavaDoc changes sent out for code review round 1. This version is relative to JDK6_23.
21-09-2010