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 141947 - race condition on node expanding
Summary: race condition on node expanding
Status: RESOLVED DUPLICATE of bug 140458
Alias: None
Product: platform
Classification: Unclassified
Component: Nodes (show other bugs)
Version: 6.x
Hardware: All All
: P1 blocker (vote)
Assignee: t_h
URL:
Keywords:
Depends on:
Blocks: 140788
  Show dependency tree
 
Reported: 2008-07-28 20:56 UTC by Viktor Lapitski
Modified: 2008-12-22 16:46 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 Viktor Lapitski 2008-07-28 20:56:18 UTC
The bug manifests itself as IZ 140788.

To observe what is described below put a breakpoint 
 inside org.openide.nodes.EntrySupport$Default.getArray() method.

While processing  expansion of a node in project tree 
the AWT-EventQueue thread posts a request into RequestProcessor
at org.openide.explorer.view.TreeView.prepareWaitCursor(). Thus 2 threads 
would execute  org.openide.nodes.EntrySupport$Default.getArray() method.


Scenario 1.
If AWT-EventQueue thread gets first into the getArray() method it 
will successfully execute 

            if (doInitialize) {
...
                    children.callAddNotify();
...

"children calculation" branch, while RequestProcessor will be waiting 
in the "else" branch for the calculation to be completed.


Scenario 2.
If RequestProcessor thread gets first into the getArray() method it 
will be executing the "children calculation" branch. Unfortunately 
the AWT-EventQueue (which at the moment is processing the node 
expansion mouse click) willn't be waiting on the "else" branch for
 the "children calculation" to be completed. The reason is that 
the AWT-EventQueue has already obtained these Children's MUTEX.readAccess() 
back at
         at org.openide.explorer.view.TreeView$ExplorerTree$GuardedActions.<init>
(TreeView.java:2043)

Thus the check in the "else" branch of getArray() method 

                    if (Children.MUTEX.isReadAccess() || Children.MUTEX.isWriteAccess() || (initThread ==
Thread.currentThread())) {                

will produce "true". So the getNodes() executed in AWT-EventQueue at


        ...
        at org.openide.nodes.EntrySupport$Default.getNodes(EntrySupport.java:153
)
        ...
        at org.openide.explorer.view.VisualizerNode.getChildren(VisualizerNode.j
ava:250)
        at org.openide.explorer.view.VisualizerNode.getChildCount(VisualizerNode
.java:324)
        at javax.swing.tree.DefaultTreeModel.getChildCount(DefaultTreeModel.java
:168)
        ...

would return empty set of children.   

The RequestProcessor who is executing 
                    children.callAddNotify();

in the "children calculation" branch wouldn't be able to execute it as 
the writeRequests generated for the mutex are put on hold until 
readAccess is relinquished by AWT-EventQueue ( ie. until AWT-EventQueue 
returns well above (in the call stack) getNodes() whcih already 
produced empty set of children)

Thus mouse click to expand a node would produce no children-nodes 
under the node.
Comment 1 t_h 2008-07-28 21:22:27 UTC
Dangerous locking in TreeView should be already removed - see #140458. Can you please check if this issue is still valid?
Comment 2 George Vasick 2008-07-28 21:38:55 UTC
We last pulled from golden on the 24th.  It looks like the fix for issue 140458 was integrated on the 25th.  We'll
verify against main.

Thanks,
George
Comment 3 t_h 2008-07-29 12:36:49 UTC
Closing as duplicate of #140458. Please reopen if problem still exists.

*** This issue has been marked as a duplicate of 140458 ***