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 128134

Summary: Got change from org.netbeans.spi.project.support.ant.PropertyUtils$SequentialPropertyEvaluator@a866d6 rather than current delegate org.netbeans.spi.project.support.ant.PropertyUtils$SequentialProperty
Product: projects Reporter: Lukas Jungmann <jungi>
Component: Ant FreeformAssignee: Milan Kubec <mkubec>
Status: RESOLVED FIXED    
Severity: blocker CC: alexvsimon, bogaerbr, dkonecny, gorrus, jglick, krystyna, mohhmekk, sflemming, theanuradha
Priority: P3 Keywords: THREAD
Version: 6.x   
Hardware: All   
OS: All   
URL: http://statistics.netbeans.org/exceptions/detail.do?id=1008
Issue Type: DEFECT Exception Reporter: 1008
Attachments: stacktrace
stacktrace
stacktrace
stacktrace
stacktrace
stacktrace
stacktrace
suggested patch
stacktrace
stacktrace
stacktrace
stacktrace
stacktrace
stacktrace

Description Lukas Jungmann 2008-02-22 11:39:44 UTC
Build: NetBeans IDE Dev (Build 20080222095138)
VM: Java HotSpot(TM) Client VM, 10.0-b19
OS: Windows Vista, 6.0, x86

User Comments: 
-start IDE with fresh userdir
-register sources from main repo in the favorites view
-create new "user.build.properties" in nbbuild
-edit it (add cluster.config and nbjdk.home props there), save it

=> AssertionError: Got change from org.netbeans.spi.project.support.ant.PropertyUtils$SequentialPropertyEvaluator@a866d6 rather than current delegate org.netbeans.spi.project.support.ant.PropertyUtils$SequentialPropertyEvaluator@1acdb96
Comment 1 Lukas Jungmann 2008-02-22 11:39:52 UTC
Created attachment 57056 [details]
stacktrace
Comment 2 Tomas Mysik 2008-02-28 14:57:59 UTC
Build: NetBeans IDE Dev (Build 20080228095928)
VM: Java HotSpot(TM) Server VM, 10.0-b19
OS: Linux, 2.6.24-gentoo-r2, i386

User Comments: 
nothing (maybe scrolling using mouse wheel)
Comment 3 Tomas Mysik 2008-02-28 14:58:02 UTC
Created attachment 57455 [details]
stacktrace
Comment 4 Erno Mononen 2008-04-02 14:19:04 UTC
Build: NetBeans IDE Dev (Build 200803302302)
VM: Java HotSpot(TM) Client VM, 10.0-b19, Java(TM) SE Runtime Environment, 1.6.0_05-b13
OS: Linux, 2.6.22-14-386, i386

User Comments: 
Comment 5 Erno Mononen 2008-04-02 14:19:08 UTC
Created attachment 59546 [details]
stacktrace
Comment 6 Vladimir Voskresensky 2008-04-10 17:46:49 UTC
Build: NetBeans IDE Dev (Build 080410)
VM: Java HotSpot(TM) Client VM, 10.0-b19, Java(TM) SE Runtime Environment, 1.6.0_05-b13
OS: Linux, 2.6.22-14-generic, i386

User Comments: 
Comment 7 Vladimir Voskresensky 2008-04-10 17:46:53 UTC
Created attachment 60004 [details]
stacktrace
Comment 8 Jesse Glick 2008-04-10 17:49:24 UTC
Obviously not in 6.1, please reevaluate.
Comment 9 Milan Kubec 2008-06-20 15:08:31 UTC
*** Issue 66195 has been marked as a duplicate of this issue. ***
Comment 10 Jesse Glick 2008-07-16 20:51:22 UTC
Build: NetBeans IDE Dev (Build 080715)
VM: Java HotSpot(TM) Client VM, 10.0-b19, Java(TM) SE Runtime Environment, 1.6.0_04-b12
OS: Windows Vista, 6.0, x86

User Comments: 
Had selected Build with Dependencies on projectui.
Failed due to nbjdk.home being set to JDK 6.
From a shell, I created nbbuild/user.build.properties pointing to JDK 5.
Back in NB, selected Build > Repeat Build.
Around that time this exception was thrown.
Comment 11 Jesse Glick 2008-07-16 20:51:26 UTC
Created attachment 64764 [details]
stacktrace
Comment 12 _ theanuradha 2008-08-27 07:05:57 UTC
Build: NetBeans IDE Dev (Build 080826)
VM: Java HotSpot(TM) Client VM, 11.0-b14, Java(TM) SE Runtime Environment, 1.6.0_10-rc-b27
OS: Windows XP, 5.1, x86

User Comments: 


Stacktrace: 
java.lang.AssertionError: Got change from org.netbeans.spi.project.support.ant.PropertyUtils$SequentialPropertyEvaluator@1775b59 rather than current delegate org.netbeans.spi.project.support.ant.PropertyUtils$SequentialPropertyEvaluator@13e1388
        at org.netbeans.modules.ant.freeform.FreeformEvaluator.propertyChange(FreeformEvaluator.java:181)
        at org.netbeans.spi.project.support.ant.PropertyUtils$SequentialPropertyEvaluator.stateChanged(PropertyUtils.java:874)
        at org.openide.util.WeakListenerImpl$Change.stateChanged(WeakListenerImpl.java:319)
        at org.openide.util.ChangeSupport.fireChange(ChangeSupport.java:123)
        at org.openide.util.ChangeSupport.fireChange(ChangeSupport.java:109)
        at org.netbeans.spi.project.support.ant.PropertyUtils$FilePropertyProvider$1.run(PropertyUtils.java:291)
Comment 13 _ theanuradha 2008-08-27 07:06:07 UTC
Created attachment 68407 [details]
stacktrace
Comment 14 Lukas Hasik 2008-09-05 15:19:23 UTC
13 duplicates in exception reporter. Latest from 080826. 
Comment 15 Lukas Hasik 2008-09-14 21:51:16 UTC
Build: NetBeans IDE Dev (Build 200809120201)
VM: Java HotSpot(TM) Client VM, 11.0-b11, Java(TM) SE Runtime Environment, 1.6.0_10-beta-b14
OS: Windows XP, 5.1, x86

User Comments: 
I was just working with nb modules in IDE
-opened projects - ColorChooser, Freeform Ant Projects, IDE Platform, Paint, Paint Application

Stacktrace: 
java.lang.AssertionError: Got change from org.netbeans.spi.project.support.ant.PropertyUtils$SequentialPropertyEvaluator@1001fd2 rather than current delegate org.netbeans.spi.project.support.ant.PropertyUtils$SequentialPropertyEvaluator@c66f48
        at org.netbeans.modules.ant.freeform.FreeformEvaluator.propertyChange(FreeformEvaluator.java:181)
        at org.netbeans.spi.project.support.ant.PropertyUtils$SequentialPropertyEvaluator.stateChanged(PropertyUtils.java:874)
        at org.openide.util.WeakListenerImpl$Change.stateChanged(WeakListenerImpl.java:319)
        at org.openide.util.ChangeSupport.fireChange(ChangeSupport.java:123)
        at org.openide.util.ChangeSupport.fireChange(ChangeSupport.java:109)
        at org.netbeans.spi.project.support.ant.PropertyUtils$FilePropertyProvider$1.run(PropertyUtils.java:291)
Comment 16 Lukas Hasik 2008-09-14 21:51:20 UTC
Created attachment 69826 [details]
stacktrace
Comment 17 Antonin Nebuzelsky 2008-09-25 10:54:58 UTC
Milosi, take this one.
Comment 18 Milos Kleint 2008-09-26 12:06:55 UTC
Created attachment 70667 [details]
suggested patch
Comment 19 Milos Kleint 2008-09-26 12:16:00 UTC
Attached is the suggested patch. It synchronizes access to the intermediateEvaluators list, but still it can happen that
an even arrives from the old intermediateEvaluators members when the current list gets recreated.
I'm not sure why the assert is even there, it seems the safest change would be to just plainly delete the assert and
fire change only if source==delegate.

I'm not pushing the changes myself as it seems to increase the likelihood  of some tests to fail. No idea why, it's
incomprehensible what the tests do.
Comment 20 Jesse Glick 2008-09-26 16:20:25 UTC
The assertion is there because init says:

        if (delegate != null) {
            delegate.removePropertyChangeListener(this);
        }
        delegate = initEval();
        delegate.addPropertyChangeListener(this);

meaning that we should only be receiving events from the current delegate to begin with. There might be a race condition
if two threads run this block of code at once, with the second thread overwriting the first thread's value of delegate
without removing the PCL from the first thread's computed delegate. Possible fix would be something like:

PropertyEvaluator newDelegate = initEval();
synchronized (somePrivateLock) {
  if (delegate != null) {
    delegate.removePropertyChangeListener(this);
  }
  newDelegate.addPropertyChangeListener(this);
}
Comment 21 Exceptions Reporter 2008-10-08 15:46:41 UTC
This issue has already 20 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=1008
Comment 22 Milan Kubec 2008-10-10 09:44:47 UTC
Not really a P2 issue, lowering priority back to P3.
Comment 23 mohhmekk 2008-10-19 00:24:17 UTC
Build: NetBeans IDE Dev (Build 200810181401)
VM: Java HotSpot(TM) Client VM, 10.0-b23, Java(TM) SE Runtime Environment, 1.6.0_07-b06
OS: Linux, 2.6.25.17-jen67-pae, i386

User Comments: 


Stacktrace: 
java.lang.AssertionError: Got change from org.netbeans.spi.project.support.ant.PropertyUtils$SequentialPropertyEvaluator@1974e21 rather than current delegate org.netbeans.spi.project.support.ant.PropertyUtils$SequentialPropertyEvaluator@81e6b0
        at org.netbeans.modules.ant.freeform.FreeformEvaluator.propertyChange(FreeformEvaluator.java:181)
        at org.netbeans.spi.project.support.ant.PropertyUtils$SequentialPropertyEvaluator.stateChanged(PropertyUtils.java:876)
        at org.openide.util.WeakListenerImpl$Change.stateChanged(WeakListenerImpl.java:319)
        at org.openide.util.ChangeSupport.fireChange(ChangeSupport.java:123)
        at org.openide.util.ChangeSupport.fireChange(ChangeSupport.java:109)
        at org.netbeans.spi.project.support.ant.PropertyUtils$FilePropertyProvider$1.run(PropertyUtils.java:293)
Comment 24 mohhmekk 2008-10-19 00:24:27 UTC
Created attachment 72202 [details]
stacktrace
Comment 25 Jesse Glick 2008-11-10 19:54:23 UTC
Build: NetBeans IDE Dev (Build 081107)
VM: Java HotSpot(TM) Client VM, 11.0-b15, Java(TM) SE Runtime Environment, 1.6.0_10-b33
OS: Linux, 2.6.27-7-generic, i386

User Comments: 
Changing nbjdk.home values in nbbuild/user.build.properties and ~/.nbbuild.properties about the same time.

Stacktrace: 
java.lang.AssertionError: Got change from org.netbeans.spi.project.support.ant.PropertyUtils$SequentialPropertyEvaluator@752e57 rather than current delegate org.netbeans.spi.project.support.ant.PropertyUtils$SequentialPropertyEvaluator@1f36b30
        at org.netbeans.modules.ant.freeform.FreeformEvaluator.propertyChange(FreeformEvaluator.java:181)
        at org.netbeans.spi.project.support.ant.PropertyUtils$SequentialPropertyEvaluator.stateChanged(PropertyUtils.java:876)
        at org.openide.util.WeakListenerImpl$Change.stateChanged(WeakListenerImpl.java:319)
        at org.openide.util.ChangeSupport.fireChange(ChangeSupport.java:123)
        at org.openide.util.ChangeSupport.fireChange(ChangeSupport.java:109)
        at org.netbeans.spi.project.support.ant.PropertyUtils$FilePropertyProvider$.run(PropertyUtils.java:293)
Comment 26 Jesse Glick 2008-11-10 19:54:27 UTC
Created attachment 73594 [details]
stacktrace
Comment 27 _ krystyna 2008-12-18 19:13:32 UTC
Build: NetBeans IDE Dev (Build 200812170242)
VM: Java HotSpot(TM) Client VM, 11.0-b13, Java(TM) SE Runtime Environment, 1.6.0_10-rc-b26
OS: Windows XP, 5.1, x86

User Comments: 
Save file on properties filed opened in Favorites window

Stacktrace: 
java.lang.AssertionError: Got change from org.netbeans.spi.project.support.ant.PropertyUtils$SequentialPropertyEvaluator@1d6d501 rather than current delegate org.netbeans.spi.project.support.ant.PropertyUtils$SequentialPropertyEvaluator@17b9c87
        at org.netbeans.modules.ant.freeform.FreeformEvaluator.propertyChange(FreeformEvaluator.java:181)
        at org.netbeans.spi.project.support.ant.PropertyUtils$SequentialPropertyEvaluator.stateChanged(PropertyUtils.java:876)
        at org.openide.util.WeakListenerImpl$Change.stateChanged(WeakListenerImpl.java:319)
        at org.openide.util.ChangeSupport.fireChange(ChangeSupport.java:123)
        at org.openide.util.ChangeSupport.fireChange(ChangeSupport.java:109)
        at org.netbeans.spi.project.support.ant.PropertyUtils$FilePropertyProvider$1.run(PropertyUtils.java:293)
Comment 28 _ krystyna 2008-12-18 19:13:48 UTC
Created attachment 75152 [details]
stacktrace
Comment 29 Jesse Glick 2009-01-12 22:44:55 UTC
Build: NetBeans IDE Dev (Build 090112)
VM: Java HotSpot(TM) Client VM, 11.0-b16, Java(TM) SE Runtime Environment, 1.6.0_11-b03
OS: Linux, 2.6.27-9-generic, i386

User Comments: 
Added nbjdk.home=.../jdk6 and permit.jdk6.builds=true to nbbuild/user.build.properties.

Stacktrace: 
java.lang.AssertionError: Got change from org.netbeans.spi.project.support.ant.PropertyUtils$SequentialPropertyEvaluator@135e847 rather than current delegate org.netbeans.spi.project.support.ant.PropertyUtils$SequentialPropertyEvaluator@1831a0c
        at org.netbeans.modules.ant.freeform.FreeformEvaluator.propertyChange(FreeformEvaluator.java:181)
        at org.netbeans.spi.project.support.ant.PropertyUtils$SequentialPropertyEvaluator.stateChanged(PropertyUtils.java:876)
        at org.openide.util.WeakListenerImpl$Change.stateChanged(WeakListenerImpl.java:319)
        at org.openide.util.ChangeSupport.fireChange(ChangeSupport.java:123)
        at org.openide.util.ChangeSupport.fireChange(ChangeSupport.java:109)
        at org.netbeans.spi.project.support.ant.PropertyUtils$FilePropertyProvider$1.run(PropertyUtils.java:293)
Comment 30 Jesse Glick 2009-01-12 22:44:59 UTC
Created attachment 75721 [details]
stacktrace
Comment 31 _ theanuradha 2009-03-24 06:56:41 UTC
Build: NetBeans IDE Dev (Build 20090321211250)
VM: OpenJDK Client VM, 14.0-b10, Java(TM) SE Runtime Environment, 1.6.0_14-ea-b01
OS: Windows XP, 5.1, x86

User Comments: 
when I run traget and stop it vis OUTput  view action 

Stacktrace: 
java.lang.AssertionError: Got change from org.netbeans.spi.project.support.ant.PropertyUtils$SequentialPropertyEvaluator@1023e4c rather than current delegate org.netbeans.spi.project.support.ant.PropertyUtils$SequentialPropertyEvaluator@6cf2bf
        at org.netbeans.modules.ant.freeform.FreeformEvaluator.propertyChange(FreeformEvaluator.java:181)
        at org.netbeans.spi.project.support.ant.PropertyUtils$SequentialPropertyEvaluator.stateChanged(PropertyUtils.java:876)
        at org.openide.util.WeakListenerImpl$Change.stateChanged(WeakListenerImpl.java:320)
        at org.openide.util.ChangeSupport.fireChange(ChangeSupport.java:123)
        at org.openide.util.ChangeSupport.fireChange(ChangeSupport.java:109)
        at org.netbeans.spi.project.support.ant.PropertyUtils$FilePropertyProvider$1.run(PropertyUtils.java:293)
Comment 32 _ theanuradha 2009-03-24 06:56:46 UTC
Created attachment 78716 [details]
stacktrace
Comment 33 Jesse Glick 2009-04-06 18:55:05 UTC
Seems reproducible to me, is it going to be fixed?
Comment 34 _ theanuradha 2009-04-09 06:47:32 UTC
Build: NetBeans IDE Dev (Build 20090402004259)
VM: OpenJDK Client VM, 14.0-b10, Java(TM) SE Runtime Environment, 1.6.0_14-ea-b01
OS: Windows XP, 5.1, x86

User Comments: 
When build ant base project

Stacktrace: 
java.lang.AssertionError: Got change from org.netbeans.spi.project.support.ant.PropertyUtils$SequentialPropertyEvaluator@118e80f rather than current delegate org.netbeans.spi.project.support.ant.PropertyUtils$SequentialPropertyEvaluator@1632a05
        at org.netbeans.modules.ant.freeform.FreeformEvaluator.propertyChange(FreeformEvaluator.java:181)
        at org.netbeans.spi.project.support.ant.PropertyUtils$SequentialPropertyEvaluator.stateChanged(PropertyUtils.java:876)
        at org.openide.util.WeakListenerImpl$Change.stateChanged(WeakListenerImpl.java:320)
        at org.openide.util.ChangeSupport.fireChange(ChangeSupport.java:123)
        at org.openide.util.ChangeSupport.fireChange(ChangeSupport.java:109)
        at org.netbeans.spi.project.support.ant.PropertyUtils$FilePropertyProvider$1.run(PropertyUtils.java:293)
Comment 35 _ theanuradha 2009-04-09 06:47:37 UTC
Created attachment 79797 [details]
stacktrace
Comment 36 David Konecny 2009-04-28 23:52:25 UTC
Always reproducible to me.
Comment 37 Milan Kubec 2009-04-29 10:10:17 UTC
Reproducible for me too, but not always.

I tried Jesse's suggested fix, but no difference, still reproducible. Then I tried Milos's idea and again no difference,
still reproducible.
Comment 38 Milan Kubec 2009-04-30 13:50:28 UTC
The problem is following (based on test case with user.build.properties file):

1) add two properties into the file, save the file
2) first PropertyChangeEvent with one of those properties is fired from source A
3) fireAnyChange() -> init() -> initEval() is called
4) old intermediateEvaluators are removed and listeners removed from them (including source A)
5) new intermediateEvaluators are created
6) THE PROBLEM: second PropertyChangeEvent with second of those properties is fired from source A, which was already
removed from intermediateEvaluators

Either logic in this class is broken or only one PropertyChangeEvent should be fired for one save operation on the
property file.

Jesse, which assumption is correct?
Comment 39 Jesse Glick 2009-05-01 16:36:12 UTC
"second PropertyChangeEvent with second of those properties is fired from source A" - sure, correct. "which was already
removed from intermediateEvaluators" - that's OK too, but why is the evaluator receiving this event, if it already
detached itself as a listener?

SequentialPropertyEvaluator is suspicious:

                PropertyChangeListener[] _listeners;
                synchronized (listeners) {
                    _listeners = listeners.toArray(new PropertyChangeListener[listeners.size()]);
                }
                for (PropertyChangeListener l : _listeners) {
                    for (PropertyChangeEvent ev : events) {
                        l.propertyChange(ev);
                    }
                }

Probably it should be using the standard PropertyChangeSupport rather than keeping List<PropertyChangeListener>
listeners. Still this does not explain why it is firing an event to a listener which has already been removed.
Comment 40 Milan Kubec 2009-05-04 09:44:53 UTC
Using PropertyChangeSupport instead of list of listeners fixes the problem.

http://hg.netbeans.org/core-main/rev/6e3881a4e264
Comment 41 Jesse Glick 2009-05-04 17:21:50 UTC
Looking at the original source again, I guess the root problem is that the listener list was copied _before_ any events
were delivered, and there can be more than one event (in the inner loop); whereas when using PropertyChangeSupport, the
first event is delivered to all listeners (as a result of which the list of listeners can change), then the second event
is delivered, and so on.
Comment 42 Quality Engineering 2009-05-04 19:05:07 UTC
Integrated into 'main-golden', will be available in build *200905041401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/6e3881a4e264
User: Milan Kubec <mkubec@netbeans.org>
Log: #128134: using PropertyChangeSupport rather than list of listeners; added sync. to init() in FreefromEvaluator