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.
[030408] Try to remove initComponents() method in the Explorer. IllegalStateException is thrown, but user friendly message "attempt to remove guarded block" should appear. This is a regression. See similar already fixed issues (and their duplicates) issue 9512 issue 22106 issue 21807
Created attachment 9850 [details] IllegalStateException
On the other hand I must admit, that there is no data loss nor deadlock, just misleading message. Please evaluate.
Created attachment 9852 [details] Full exception stacktrace
The previous exceptions has been reproduced while trying modify the source code via Java hierarchy API. Click on the guarded method initComponents(), invoke editor context menu, choose customize, try to change the return type
Problem: after two atomicLocks the atomicDepth is set to level 1. After unsuccessful operation in runAtomicAsUser the breakAtomicLock method is called, which set the atomicDepth to 0. Then after the atomicUnlock is called two times the exception is thrown. Also two times. The javadoc of the method breakAtomicLock says: "Even after calling this method, the atomicUnlock() must still be called." In this case I would recommend do not set the value of atomicDepth to 0.
Mato is right, it's necessary to remove setting of the atomicDepth to zero in the breakAtomicLock(). This regression resluted from a change that I've made in the atomicUnlock() about two months ago. Originally it was possible to call atomicUnlock() even though there was no corresponding atomicLock() called before it. I've changed that to throw an exception in such case because IMO it's a serious programatic error. Unfortunately this revealed a bug (setting atomicDepth to zero) in the breakAtomicLock() that was present there for a long time. I consider the issue to be a serious regression as any NbDocument.runAtomicAsUser() touching the guarded section will throw the annoying exception. If nobody objects I would like to fix the issue in release35 too. Fixed in the main trunk: Checking in libsrc/org/netbeans/editor/BaseDocument.java; /cvs/editor/libsrc/org/netbeans/editor/BaseDocument.java,v <-- BaseDocument.java new revision: 1.97; previous revision: 1.96
Visuall diff is at http://www.netbeans.org/source/browse/editor/libsrc/org/netbeans/editor/BaseDocument.java.diff?r1=1.96&r2=1.97
Created attachment 9869 [details] Binary patch for release35: Please use the attached jar to replace the corresponding classes in modules/ext/nb-editor.jar
I verified the patch for release35.
waiting for code review...
Yes, the fix is OK. I have already approve it ;-)
approved for 3.5
Integrated into release35: Checking in libsrc/org/netbeans/editor/BaseDocument.java; /cvs/editor/libsrc/org/netbeans/editor/BaseDocument.java,v <-- BaseDocument.java new revision: 1.92.2.2; previous revision: 1.92.2.1
Verified in release 35 build 200304132350.