United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-4481696 LOGGING APIs: spec for LogManager.getProperty(String) needs clarification
JDK-4481696 : LOGGING APIs: spec for LogManager.getProperty(String) needs clarification

Details
Type:
Bug
Submit Date:
2001-07-19
Status:
Closed
Updated Date:
2003-10-29
Project Name:
JDK
Resolved Date:
2003-08-30
Component:
core-libs
OS:
generic
Sub-Component:
java.util.logging
CPU:
generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.4.0
Fixed Versions:
5.0 (tiger)

Related Reports

Sub Tasks

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
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);
    }
                                     
2004-06-11
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
tiger

FIXED IN:
tiger

INTEGRATED IN:
tiger
tiger-b18

VERIFIED IN:
tiger


                                     
2004-06-14



Hardware and Software, Engineered to Work Together