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 187844

Summary: StackOverflowError at ChildrenArray.nodes
Product: platform Reporter: jyeary <jyeary>
Component: NodesAssignee: Jaroslav Tulach <jtulach>
Status: RESOLVED WORKSFORME    
Severity: normal CC: adam_myatt, djohns505, gionn, happy_2010, hmdmph, ivar_grimstad, jmichelberger, jraanamo, jtulach, kaisuchomel, kurti, mmirilovic, mperezma, pmatth, rajeshbhatiya, sbentzen, teras, uwe_pachler
Priority: P2    
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter: 170219
Attachments: stacktrace
stacktrace
stacktrace

Description jyeary 2010-06-20 01:12:27 UTC
Build: NetBeans IDE 6.9 (Build 201006101454)
VM: Java HotSpot(TM) 64-Bit Server VM, 16.3-b01-279, Java(TM) SE Runtime Environment, 1.6.0_20-b02-279-10M3065
OS: Mac OS X

User Comments:
GUEST: opening a project

jyeary: Running GlassFish 3.0.1 in background while working on sample Swing application in foreground.

GUEST: This occured during startup




Stacktrace: 
java.lang.StackOverflowError
   at org.openide.util.Mutex.leave(Mutex.java:835)
   at org.openide.util.Mutex$Privileged.exitReadAccess(Mutex.java:1669)
   at org.openide.nodes.EntrySupport$Default.getNodes(EntrySupport.java:182)
   at org.openide.nodes.EntrySupport$Default.getNodes(EntrySupport.java:225)
   at org.openide.nodes.Children.getNodes(Children.java:448)
   at org.openide.nodes.Node.assignTo(Node.java:339)
Comment 1 jyeary 2010-06-20 01:12:31 UTC
Created attachment 100248 [details]
stacktrace
Comment 2 Jaroslav Tulach 2010-06-29 17:21:26 UTC
Is this interesting for Nejedlák?
Comment 3 Exceptions Reporter 2010-07-07 17:23:35 UTC
This bug already has 10 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=170219
Comment 4 adam_myatt 2010-09-13 17:14:44 UTC
Created attachment 102002 [details]
stacktrace

opening Andoird project
Comment 5 mperezma 2010-12-08 23:48:50 UTC
Created attachment 103778 [details]
stacktrace

Opening a svn-controlled project, in wich ".svn" folder has been removed frome project root folder (although some child folders still having their ".svn" folder)
Comment 6 Marian Mirilovic 2011-02-18 13:57:57 UTC
120 dups - at least P2 (reported also in NB 7.0 Beta 2)
Comment 7 Jaroslav Tulach 2011-02-18 17:34:31 UTC
This is probably an error in Node's usage, then an error in Nodes infrastructure. The stack overflowis generated while constructing an error message for to be thrown IllegalStateException. So something has been wrong before the StackOverFlowError.

I've made the code more robust in ergonomics#14c06bbc5ed9
Comment 8 Quality Engineering 2011-02-20 10:33:53 UTC
Integrated into 'main-golden', will be available in build *201102200501* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/14c06bbc5ed9
User: Jaroslav Tulach <jtulach@netbeans.org>
Log: #187844: Sometimes StackOverflowException is thrown when we attempt to assemble the exception message. Catch it.
Comment 9 Jaroslav Tulach 2011-03-11 08:28:31 UTC
*** Bug 196541 has been marked as a duplicate of this bug. ***
Comment 10 jsmith5and5 2011-05-09 14:54:05 UTC
I recently had the same problem and fixed it.

Problem: The same StackOverflowError occurred when I opened my NetBeans Platform application and expanded the project tree right away before the project had the chance to fully initialize. The result of the error was that the project tree showed as empty. To be clear, if the project was allowed to fully load, i.e. the user waits some time before expanding the tree, there was no problem.

Solution: The problem was in my NodeFactory.createNodes implementation for my project type. The (broken) implementation was something like this (I've simplified it to its essentials):

MyFileSystem fs = ...
FileObject root = fs.getRoot();
DataObject data = DataObject.find(root);
Node node = dataObject.getNodeDelegate();
return NodeFactorySupport.fixedNodeList(node);



Now, if the user waits for everything to load, createNodes is called only once and everything is fine. However, if the user expands the project tree before the project is loaded, createNodes is called twice: once for the user click and presumably once again when NB calls it programatically as part of its normal project load tasks. The StackOverflowError occurs during the second call. It fails because the node is already added to a parent from the first call.

Therefore, my solution was to create different top-level node instances each time createNodes was called by wrapping the nodes artificially with FilterNodes.

The NodeFactory.createNodes javadoc doesn't say anything about not allowing shared node instances for top-level nodes. Also, that doesn't really seem right to require that given that each DataObject is supposed to have only one node instance by design.

I'm not familiar enough with the code to judge the effort involved in making changes, but in my opinion, my first implementation of createNodes was reasonable and should have worked. Given the number of duplicates this bug has, I think I'm not alone. :)

P.S. I hope it's cool to comment on a resolved bug. This just seemed the best place for this.