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.
I created a folder /tmp/www and opened it (with contrib/htmlprojects installed). The following exception was thrown. The line it occurs at is: Set<? extends Project> subprojects = cache.get(p); I'd hazard a guess that it's some kind of race condition, but who knows. I don't think the HTML project is doing anything wrong here (note it does not have much in its lookup). java.lang.NullPointerException at org.netbeans.modules.project.ui.ProjectChooserAccessory.addSubprojects(ProjectChooserAccessory.java:379) at org.netbeans.modules.project.ui.ProjectChooserAccessory$ModelUpdater.run(ProjectChooserAccessory.java:647) at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:525) [catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:957)
I got the same NPE when opening a j2se project inside trunk, using a fresh userdir. However, the project opened without any problems. ---- NetBeans IDE Dev (Build 200609101800) 1.6.0-rc; Java HotSpot(TM) 64-Bit Server VM 1.6.0-rc-b98 SunOS version 5.10 running on sparcv9 en (nb); ISO646-US
Created attachment 33748 [details] Should fix the problem
The attached patch *should* fix the problem. The only way I can see that the NPE can happen is if removeNotify() is called in another thread after the null-check in ModelUpdater. It certainly could happen. I did not stop the ModelUpdater from running if the cache is nulled, after it is running, I just added synchronization to removeNotify() and ModelUpdater's access of subprojectsCache, which will copy it into a local variable. That will fix the NPE. Someone who knows how fast the code is in ModelUpdater may be able to provide a cleaner patch - I didn't want to put the loop inside a synchronized block, or synchronize all accesses to ModelUpdater inside the loop. So this approach synchronizes the minimum number of lines of code, which seemed the safest approach in code I don't know well. An unsynchronized null-check of the subprojectCache instance variable inside the loop is probably safe - object pointer writes may not be atomic in Java, but AFAIK the value will only be null if a write to set it to null has been completed.
Created attachment 33749 [details] Sorry, this is the corrected patch
duplicate of #90745, fixed in trunk. *** This issue has been marked as a duplicate of 90745 ***