JDK-4941938 : java.util.logging.Logger.throwing() is calling doLog() without testing offValue
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util.logging
  • Affected Version: 1.4.2
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2003-10-22
  • Updated: 2017-05-16
  • Resolved: 2003-12-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.
Other
5.0 b32Fixed
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
14-06-2004

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
08-12-2003