JDK-4481696 : LOGGING APIs: spec for LogManager.getProperty(String) needs clarification
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util.logging
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2001-07-19
  • Updated: 2017-05-16
  • Resolved: 2003-08-30
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.
Other
5.0 tigerFixed
Description

Name: elR10090			Date: 07/19/2001



The following is the current (from Merlin-b70) specification for the method
java.util.logging.LogManager.getProperty(String).

    public String getProperty(String name)
    
    Get the value of a logging property. 
    
    Parameters: name - property name
    Returns: property value
    
The spec does not specify what value will be returned if the property is not
found. 

Since all logging properties are stored in java.util.Properties format let us
check this situation in java.util.Properties class.

Spec for the method Properties.getProperty(String)

    public String getProperty(String key)
    
    Searches for the property with the specified key in this property list. 
    If the key is not found in this property list, the default property list,
    and its defaults, recursively, are then checked. The method returns null 
    if the property is not found. 
    
    Parameters: key - the property key.
    Returns: the value in this property list with the specified key value.

says that null will be returned "if the property is not found". Please, note, 
the 
same behavior (the method returns null if property is not found) is specified in
java.lang.System.getProperty(String).

I believe the same remark should be documented in the 
LogManager.getProperty(String) 
method.

The following test shows that LogManager.getProperty(String) returns
null if the property is not found with the given name.

import java.util.logging.*;
import java.io.*;

public class Test {
    final static LogManager logManager = LogManager.getLogManager();

    public static void main (String args[]) {
        System.exit(95 + run(args, System.out));
    }

    public static int run(String args[], PrintStream out) {
        String property1;
        String property2;        
        
        property1 = logManager.getProperty("");
        out.println("# Property 1 is " + property1);
        
        property2 = logManager.getProperty("NO_SUCH_PROPERTY");
        out.println("# Property 2 is " + property2);

        return 0;
    }
}

The test outputs

# Property 1 is null
# Property 2 is null

======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger FIXED IN: tiger INTEGRATED IN: tiger tiger-b18 VERIFIED IN: tiger
14-06-2004

EVALUATION This is missing from the javadoc ###@###.### 2003-07-22 Specification update as per CCC /** * Get the value of a logging property. * The method returns null if the property is not found. * @param name property name * @return property value */ public String getProperty(String name) { return props.getProperty(name); }
11-06-2004