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 214193 - AssertionError: Node org.netbeans.modules.java.JavaNode[name=BeanC; displayName=BeanC.java][Name=BeanC, displayName=BeanC.java] returns null from getProperties() for one or more of its property sets
Summary: AssertionError: Node org.netbeans.modules.java.JavaNode[name=BeanC; displayNa...
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Nodes (show other bugs)
Version: 7.2
Hardware: All All
: P2 normal (vote)
Assignee: Jaroslav Tulach
URL:
Keywords:
: 218638 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-06-14 10:53 UTC by ttokoly
Modified: 2012-11-29 14:31 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 189490


Attachments
stacktrace (1.62 KB, text/plain)
2012-06-14 10:53 UTC, ttokoly
Details
Test case showing synchronization bug in Sheet.toArray. (2.53 KB, patch)
2012-10-28 11:59 UTC, Jan Lahoda
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description ttokoly 2012-06-14 10:53:20 UTC
This bug was originally marked as duplicate of bug 196166, that is already resolved. This bug is still valid, so this seems to be another bug, but it might be related.

Build: NetBeans IDE Dev (Build 201206140001)
VM: Java HotSpot(TM) 64-Bit Server VM, 23.1-b03, Java(TM) SE Runtime Environment, 1.7.0_05-b05
OS: Mac OS X

User Comments:
ttokoly: 1. Open two java files.
2. From tab contextual menu of first one select New Document Tab Group.
3. Open third file. Select second opened document and open fourth file.
4. Open a form file. Select a tab from other group and open a second form file.
-> this error shows up

GUEST: Starting NetBeans after an update.

bolsover: Opening IDE




Stacktrace: 
java.lang.AssertionError: Node org.netbeans.modules.java.JavaNode[name=BeanC; displayName=BeanC.java][Name=BeanC, displayName=BeanC.java] returns null from getProperties() for one or more of its property sets
   at org.openide.explorer.propertysheet.PropertySheet.setCurrentNode(PropertySheet.java:681)
   at org.openide.explorer.propertysheet.PropertySheet.doSetNodes(PropertySheet.java:467)
   at org.openide.explorer.propertysheet.PropertySheet.access$100(PropertySheet.java:117)
   at org.openide.explorer.propertysheet.PropertySheet$2$1.run(PropertySheet.java:629)
   at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
   at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:701)
Comment 1 ttokoly 2012-06-14 10:53:27 UTC
Created attachment 120830 [details]
stacktrace
Comment 2 Jaroslav Tulach 2012-06-18 07:36:36 UTC
Problem is in JavaNode, isn't it?
Comment 3 Jan Lahoda 2012-10-28 11:58:22 UTC
I do not see the bug in JavaNode, JavaNode does not override getPropertySets, it only overrides createSheet, and I do not see how were we would be passing null PropertySet there (supporting evidence: there are at least two more node implementations noted in the exceptions, incorrectly duplicated to a java.source bug!).

I do however see a synchronization bug in Sheet.toArray() itself (the array may be returned from the method *before* it is filled with data). I'll attach a test case that proves that.
Comment 4 Jan Lahoda 2012-10-28 11:59:06 UTC
Created attachment 126680 [details]
Test case showing synchronization bug in Sheet.toArray.
Comment 5 Jan Lahoda 2012-10-28 11:59:24 UTC
*** Bug 218638 has been marked as a duplicate of this bug. ***
Comment 6 Jaroslav Tulach 2012-10-29 09:13:39 UTC
ergonomics#804dabae07b6 - thanks for the test - it made me fix the issue differently than by enclosing the whole method into synchronized block.
Comment 7 Quality Engineering 2012-10-31 02:58:09 UTC
Integrated into 'main-golden', will be available in build *201210310001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/ff87db51fd7c
User: Jan Lahoda <jlahoda@netbeans.org>
Log: #214193: the synchronization guarantees of Sheet.toArray are somewhat weak, and Nodes are responsible for not returning null in their property sets, trying to do that correctly for JavaNode.
Comment 8 Quality Engineering 2012-11-01 02:45:22 UTC
Integrated into 'main-golden', will be available in build *201211010001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/804dabae07b6
User: Jaroslav Tulach <jtulach@netbeans.org>
Log: #214193: Synchronization problem in Sheet - avoid double checked locking
Comment 9 Jan Lahoda 2012-11-02 11:37:46 UTC
(In reply to comment #6)
> ergonomics#804dabae07b6 - thanks for the test - it made me fix the issue
> differently than by enclosing the whole method into synchronized block.

I think this is still incorrect - "sets" is an unsynchronized ArrayList, whose size can change between the invocation of .size() and .toArray() (or even during invocation of .toArray() as such, so cannot be easily fixed by calling toArray(empty-array), IMO).

As a side note, I don't think that the use of infinite loop is necessary, "return array;" in the second synchronized block would IMO work in the same way.
Comment 10 Jaroslav Tulach 2012-11-29 14:31:36 UTC
I don't think the criticism applies: arr can only get new fields while it is local. As soon as it becomes shared, it is effectively immutable.