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 86478 - IndexedNode default Index impl reorder method throws IllegalStateException
Summary: IndexedNode default Index impl reorder method throws IllegalStateException
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Nodes (show other bugs)
Version: 5.x
Hardware: PC Linux
: P3 blocker (vote)
Assignee: Petr Nejedly
URL:
Keywords: SIMPLEFIX
Depends on:
Blocks:
 
Reported: 2006-10-04 15:27 UTC by dhavrda
Modified: 2008-12-22 14:32 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 dhavrda 2006-10-04 15:27:19 UTC
First this also happens on 5.5 beta 2.

Description:  A read access instead of a write access is being used in the
reorder method of Index.ArrayChildren

Steps to reproduce:
1.  Create a class which extends IndexedNode.
2.  Use the constructor which takes no arguments. This will cause IndexedNode to
   use the class Index.ArrayChildren for its children and Index.
3.  Add some nodes to the instance of your IndexedNode
4.  Make sure you put the ReorderAction in your set of actions for the IndexedNode.
5.  Debug this.  Right click your IndexedNode and select Change Order.
6.  Change the order of your ndoes and click ok.

You will get an IllegalStateException because the reorder() method of
ArrayChildren found in Index is using a read access instead of a write access.

Here is the workaround if you need to use this class:
Extend the Index.ArrayChildren class and override the reorder method
       
public void reorder() {
           Mutex.Action action = new Mutex.Action(){
               public Object run(){
                   Index.Support.showIndexedCustomizer(YourChildren.this);
                   return null;
               }
           };
           MUTEX.writeAccess(action);
       } 

Here is the stack trace:

> java.lang.IllegalStateException: WARNING: Going from readAccess to
writeAccess, see #10778: http://www.netbeans.org/issues/show_bug.cgi?id=10778
>    at org.openide.util.Mutex.enter(Mutex.java:573)
>    at org.openide.util.Mutex.writeEnter(Mutex.java:509)
>    at org.openide.util.Mutex.access$100(Mutex.java:78)
>    at org.openide.util.Mutex$Privileged.enterWriteAccess(Mutex.java:1464)
>    at org.openide.nodes.Index$ArrayChildren.reorder(Index.java:333)
>    at org.openide.nodes.IndexedCustomizer.doClose(IndexedCustomizer.java:289)
>    at org.openide.nodes.TMUtil$IndexC.run(TMUtil.java:328)
>    at org.openide.nodes.TMUtil.exec(TMUtil.java:186)
>    at org.openide.nodes.TMUtil.showIndexedCustomizer(TMUtil.java:134)
>    at org.openide.nodes.Index$Support.showIndexedCustomizer(Index.java:265)
>    at org.openide.nodes.Index$ArrayChildren.reorder(Index.java:353)
>    at org.openide.actions.ReorderAction.performAction(ReorderAction.java:51)
Comment 1 Petr Nejedly 2007-09-21 22:13:21 UTC
Fixed using safer approach of postWriteRequest. Keeping the Chilren.MUTEX write-locked for excessive amount of time
(whole dialog lifetime) would be quite dangerous.
openide/nodes/src/org/openide/nodes/Index.java,v1.6