Name: rmT116609 Date: 11/14/2002
FULL PRODUCT VERSION :
java version "1.4.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)
FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 [Version5.00.2195]
A DESCRIPTION OF THE PROBLEM :
This report is based on examining the source code shipped with J2SDK
1.4.1_01.
There is a classic race condition in the implementation of
java.util.logging.Logger. The field 'filter' is only accessed in the
methods setFilter, getFilter, and log(LogRecord). Log accesses
'filter' in the following manner:
synchronized (this) {
if
(filter != null && !filter.isLoggable(record)) {
return;
}
}
That is, 'filter' is checked against null before being
dereferenced. This is done in a synchronized block presumably to prevent
'filter' from being set to null after it has been found to be non-null. The
problem is that setFilter() does not use synchronization at all, and is
explicitly allowed to set 'filter' to null. The critical section in
log(LogRecord) is thus completely useless.
Method setFilter()
should be declared synchronized to avoid the race condition. Method
getFilter() should declared synchronized otherwise the Java Memory
Model allows it to return out-of-date values.
REPRODUCIBILITY :
This bug can be reproduced rarely.
CUSTOMER WORKAROUND :
Caller of setFilter() should synchronize on the Logger object before
invoking setFilter().
(Review ID: 167038)
======================================================================