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.

View | Details | Raw Unified | Return to bug 232085
Collapse All | Expand All

(-)a/openide.loaders/src/org/openide/loaders/DataNode.java (-10 / +15 lines)
Lines 45-50 Link Here
45
package org.openide.loaders;
45
package org.openide.loaders;
46
46
47
47
48
import java.awt.EventQueue;
48
import java.awt.datatransfer.*;
49
import java.awt.datatransfer.*;
49
import java.beans.*;
50
import java.beans.*;
50
import java.io.*;
51
import java.io.*;
Lines 758-763 Link Here
758
    * @param ev event describing the change
759
    * @param ev event describing the change
759
    */
760
    */
760
    void fireChange(final PropertyChangeEvent ev) {
761
    void fireChange(final PropertyChangeEvent ev) {
762
        // If the DataObject is not valid the node should be
763
        // removed. Called always asynchronously, see bug 232085.
764
        if (DataObject.PROP_VALID.equals(ev.getPropertyName())) {
765
            EventQueue.invokeLater(new Runnable() {
766
                @Override
767
                public void run() {
768
                    Object newVal = ev.getNewValue();
769
                    if ((newVal instanceof Boolean) && (!((Boolean) newVal).booleanValue())) {
770
                        fireNodeDestroyed();
771
                    }
772
                }
773
            });
774
            return;
775
        }
761
        Mutex.EVENT.writeAccess(new Runnable() {
776
        Mutex.EVENT.writeAccess(new Runnable() {
762
            public void run() {
777
            public void run() {
763
778
Lines 786-801 Link Here
786
                    //return;
801
                    //return;
787
                } 
802
                } 
788
        
803
        
789
                // if the DataOjbect is not valid the node should be
790
                // removed
791
                if (DataObject.PROP_VALID.equals(ev.getPropertyName())) {
792
                    Object newVal = ev.getNewValue();
793
                    if ((newVal instanceof Boolean) && (!((Boolean) newVal).booleanValue())) {
794
                        fireNodeDestroyed();
795
                    }
796
                    return;
797
                } 
798
                
799
                 /*See #31413*/
804
                 /*See #31413*/
800
                List transmitProperties = Arrays.asList(new String[] {
805
                List transmitProperties = Arrays.asList(new String[] {
801
                    DataObject.PROP_NAME, DataObject.PROP_FILES, DataObject.PROP_TEMPLATE});
806
                    DataObject.PROP_NAME, DataObject.PROP_FILES, DataObject.PROP_TEMPLATE});
(-)a/openide.loaders/test/unit/src/org/openide/loaders/DataNodeTest.java (+55 lines)
Lines 44-53 Link Here
44
44
45
package org.openide.loaders;
45
package org.openide.loaders;
46
46
47
import java.awt.EventQueue;
47
import java.io.IOException;
48
import java.io.IOException;
48
import java.lang.ref.WeakReference;
49
import java.lang.ref.WeakReference;
50
import java.lang.reflect.InvocationTargetException;
49
import java.util.Enumeration;
51
import java.util.Enumeration;
50
import java.util.Set;
52
import java.util.Set;
53
import java.util.concurrent.Semaphore;
51
import java.util.logging.Level;
54
import java.util.logging.Level;
52
import java.util.logging.Logger;
55
import java.util.logging.Logger;
53
import org.netbeans.junit.NbTestCase;
56
import org.netbeans.junit.NbTestCase;
Lines 59-65 Link Here
59
import org.openide.filesystems.FileUtil;
62
import org.openide.filesystems.FileUtil;
60
import org.openide.nodes.Children;
63
import org.openide.nodes.Children;
61
import org.openide.nodes.Node;
64
import org.openide.nodes.Node;
65
import org.openide.nodes.NodeAdapter;
66
import org.openide.nodes.NodeEvent;
62
import org.openide.util.Enumerations;
67
import org.openide.util.Enumerations;
68
import org.openide.util.Exceptions;
63
import org.openide.util.Lookup;
69
import org.openide.util.Lookup;
64
import org.openide.util.lookup.Lookups;
70
import org.openide.util.lookup.Lookups;
65
import org.openide.util.test.MockLookup;
71
import org.openide.util.test.MockLookup;
Lines 235-240 Link Here
235
        assertGC("DataObject released", refD);
241
        assertGC("DataObject released", refD);
236
    }
242
    }
237
    
243
    
244
    /**
245
     * Test for bug 232085.
246
     *
247
     * @throws IOException
248
     * @throws InterruptedException
249
     * @throws InvocationTargetException
250
     */
251
    public void testDestroyedEventNotFiredUnderPoolLock() throws IOException,
252
            InterruptedException, InvocationTargetException {
253
254
        final FileSystem fs = FileUtil.createMemoryFileSystem();
255
        final FileObject fob = fs.getRoot().createData("file.txt");
256
        final DataObject dob = DataObject.find(fob);
257
        final Node n = dob.getNodeDelegate();
258
        final Semaphore s = new Semaphore(0);
259
        final boolean[] underLock = new boolean[]{true};
260
261
        n.addNodeListener(new NodeAdapter() {
262
263
            @Override
264
            public void nodeDestroyed(NodeEvent ev) {
265
                underLock[0] = DataObjectPool.isConstructorAllowed();
266
                s.release();
267
            }
268
        });
269
270
        EventQueue.invokeAndWait(new Runnable() {
271
272
            @Override
273
            public void run() {
274
                try {
275
                    DataObjectPool.getPOOL().runAtomicAction(fob,
276
                            new FileSystem.AtomicAction() {
277
278
                                @Override
279
                                public void run() throws IOException {
280
                                    dob.delete();
281
                                }
282
                            });
283
                } catch (IOException ex) {
284
                    Exceptions.printStackTrace(ex);
285
                }
286
            }
287
        });
288
        s.acquire();
289
        assertFalse("NodeDestroyed event fired from DataObjectPool's "
290
                + "'allow constructor' mode.", underLock[0]);
291
    }
292
238
    private static final class FSWithStatus extends org.openide.filesystems.LocalFileSystem 
293
    private static final class FSWithStatus extends org.openide.filesystems.LocalFileSystem 
239
    implements FileSystem.HtmlStatus {
294
    implements FileSystem.HtmlStatus {
240
        public Set lastFiles;
295
        public Set lastFiles;

Return to bug 232085