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 64665 - Children mutex going from readAccess to writeAccess
Summary: Children mutex going from readAccess to writeAccess
Status: RESOLVED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: Code (show other bugs)
Version: 5.x
Hardware: All All
: P3 blocker (vote)
Assignee: Andrei Badea
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-09-19 14:17 UTC by Andrei Badea
Modified: 2005-10-27 10:15 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Stack trace (3.95 KB, text/plain)
2005-09-19 14:18 UTC, Andrei Badea
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrei Badea 2005-09-19 14:17:40 UTC
Just received the warning about the mutex in o.o.nodes.Children going from read
to write access (see the attached stack trace). Seems caused by the Server
Resources node, which is a FilterNode which filters either the "setup" directory
in a J2EE project, or an AbstractNode (when this directory doesn't exist) and
uses FN.changeOriginal() to switch among the two. Here the SRN constructor is
called under Children.MUTEX read access and triggers the changeOriginal() method
call, which needs write access.

Not sure whose issue this is (ServerResourcesNode or FilterNode). Should
FilterNode clients be aware that they should not call FN.changeOriginal() under
Children.MUTEX read lock? If so, how would they find this out?
Comment 1 Andrei Badea 2005-09-19 14:18:18 UTC
Created attachment 24944 [details]
Stack trace
Comment 2 Petr Nejedly 2005-10-25 15:35:07 UTC
They could recognize this using mutex methods is[Read|Write]Access, but that's
not nice. Probably the FilterNode should perform changeOriginal from inside a
postWriteRequest, instead of plain writeAccess.
Comment 3 Jaroslav Tulach 2005-10-25 17:14:48 UTC
Guys, read the javadoc of the changeOriginal method. The only one who has to 
do postWriteRequest is its caller... 
 
Comment 4 Andrei Badea 2005-10-25 18:01:56 UTC
There doesn't to be anything in the Javadoc of FilterNode.changeOriginal()
suggesting that I should call postWriteAccess(). And the word mutex isn't
mentioned in the whole FN's Javadoc, so how does a user know that it's
Children.MUTEX? Jardo, could you please elaborate a bit on this?
Comment 5 Jaroslav Tulach 2005-10-25 19:12:59 UTC
Sorry, the warning was only in FilterChildren.changeXXX  
  
"#64665: Improving javadoc to mention that Children.MUTEX.writeAccess is  
needed if changing children"  
Checking in src/org/openide/nodes/FilterNode.java;  
/cvs/openide/nodes/src/org/openide/nodes/FilterNode.java,v  <--   
FilterNode.java  
new revision: 1.2; previous revision: 1.1  
done  
Checking in src/org/openide/util/actions/NodeAction.java;  
/cvs/openide/nodes/src/org/openide/util/actions/NodeAction.java,v  <--   
NodeAction.java  
new revision: 1.8; previous revision: 1.7  
  
Comment 6 Andrei Badea 2005-10-26 11:14:57 UTC
Jardo, not meaning to be picky, but the added Javadoc comment suggests that the
caller should only pay attention to the Children.MUTEX write lock if he also
changes the children. But FN.changeOriginal() *always* aquires the write lock,
regardless of the changeChildren parameter value.
Comment 7 Andrei Badea 2005-10-27 10:15:31 UTC
Fixed.

Checking in ServerResourceNode.java;
/cvs/j2ee/ejbapi/src/org/netbeans/modules/j2ee/ejbjar/project/ui/ServerResourceNode.java,v
 <--  ServerResourceNode.java
new revision: 1.2; previous revision: 1.1
done