This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 29552

Summary: Double-checked locking in FCLSupport
Product: platform Reporter: Jesse Glick <jglick>
Component: FilesystemsAssignee: rmatous <rmatous>
Status: VERIFIED FIXED    
Severity: blocker Keywords: THREAD
Priority: P4    
Version: 3.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:

Description Jesse Glick 2002-12-13 18:31:51 UTC
final void addFileChangeListener
(FileChangeListener fcl) {
        if (listeners == null) {
            synchronized (getClass ()) {
                if (listeners == null) {
                    listeners = new
EventListenerList ();
                }
            }
        }
        listeners.add (FileChangeListener.class, fcl);
    }

Suggest simply

    final synchronized void addFileChangeListener
(FileChangeListener fcl) {
        if (listeners == null) {
            listeners = new EventListenerList ();
        }
        listeners.add (FileChangeListener.class, fcl);
    }

Same in removeFileChangeListener, and in
dispatchEvent, synchronize on this just during the
first two lines:

    final void dispatchEvent (FileEvent fe, int
operation) {
        Object[] fcls;
        synchronized (this) {
            if (listeners == null) return;
            fcls = listeners.getListenerList();
        }
        // as before
Comment 1 rmatous 2003-06-06 10:29:46 UTC
Fixed in trunk according to suggestion.

RCS file: /cvs/openide/src/org/openide/filesystems/FCLSupport.java,v
new revision 1.5; pervious revision 1.4
Comment 2 Marian Mirilovic 2005-07-15 07:42:23 UTC
closed