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 - Double-checked locking in FCLSupport
Summary: Double-checked locking in FCLSupport
Status: VERIFIED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Filesystems (show other bugs)
Version: 3.x
Hardware: All All
: P4 blocker (vote)
Assignee: rmatous
URL:
Keywords: THREAD
Depends on:
Blocks:
 
Reported: 2002-12-13 18:31 UTC by Jesse Glick
Modified: 2008-12-22 18:50 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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