-
Bug
-
Resolution: Fixed
-
P4
-
1.4.2
-
b32
-
x86
-
windows_xp
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)
======================================================================