United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4941938 : java.util.logging.Logger.throwing() is calling doLog() without testing offValue

Details
Type:
Bug
Submit Date:
2003-10-22
Status:
Resolved
Updated Date:
2003-12-19
Project Name:
JDK
Resolved Date:
2003-12-19
Component:
core-libs
OS:
windows_xp
Sub-Component:
java.util.logging
CPU:
x86
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.4.2
Fixed Versions:
5.0 (b32)

Related Reports

Sub Tasks

Description

Name: rmT116609			Date: 10/22/2003


FULL PRODUCT VERSION :
C:\j2sdk1.4.2_02\bin>java -version
java version "1.4.2_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_02-b03)
Java HotSpot(TM) Client VM (build 1.4.2_02-b03, mixed mode)

FULL OS VERSION :
Windows XP Professional 2002 SP-1

A DESCRIPTION OF THE PROBLEM :
The throwing method doesn't check levelValue against offValue before calling the doLog() method as it should do :

    public void throwing(String sourceClass, String sourceMethod, Throwable thrown) {
	if (Level.FINER.intValue() < levelValue) {
	    return;
	}
	LogRecord lr = new LogRecord(Level.FINER, "THROW");
	lr.setSourceClassName(sourceClass);
	lr.setSourceMethodName(sourceMethod);
	lr.setThrown(thrown);
	doLog(lr);
    }

The corrected code should be :

    public void throwing(String sourceClass, String sourceMethod, Throwable thrown) {
	//if (Level.FINER.intValue() < levelValue) {  // INCORRECT
	if (Level.FINER.intValue() < levelValue || levelValue == offValue) { // CORRECTED
	    return;
	}
	LogRecord lr = new LogRecord(Level.FINER, "THROW");
	lr.setSourceClassName(sourceClass);
	lr.setSourceMethodName(sourceMethod);
	lr.setThrown(thrown);
	doLog(lr);
    }


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
No need to run the code to reproduce the issue. Reading all doLog() call contexts in Logger.java, the additional check is simply missing in Logger.throwing(), period.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I would have expected that Logger.throwing() doesn't log anything if the current Logger's level is Level.OFF.
ACTUAL -
Logger.throwing() will create a log entry even if its level is Level.OFF.

REPRODUCIBILITY :
This bug can be reproduced always.
(Incident Review ID: 217144) 
======================================================================

                                    

Comments
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
tiger-beta

FIXED IN:
tiger-beta

INTEGRATED IN:
tiger-b32
tiger-beta


                                     
2004-06-14
EVALUATION

Analysis in description is correct

###@###.### 2003-10-24

public void throwing(String sourceClass, String sourceMethod, Throwable
thrown) {
        
        if (Level.FINER.intValue() < levelValue || levelValue == offValue) {

###@###.### 2003-12-08
                                     
2003-12-08



Hardware and Software, Engineered to Work Together