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 83429 - NPE opening an HTML project
Summary: NPE opening an HTML project
Status: RESOLVED DUPLICATE of bug 90745
Alias: None
Product: projects
Classification: Unclassified
Component: Generic Infrastructure (show other bugs)
Version: 5.x
Hardware: All All
: P3 blocker (vote)
Assignee: Milos Kleint
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-08-24 22:09 UTC by _ tboudreau
Modified: 2007-01-03 11:37 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Should fix the problem (1.39 KB, application/octet-stream)
2006-09-11 09:43 UTC, _ tboudreau
Details
Sorry, this is the corrected patch (2.02 KB, application/octet-stream)
2006-09-11 09:51 UTC, _ tboudreau
Details

Note You need to log in before you can comment on or make changes to this bug.
Description _ tboudreau 2006-08-24 22:09:20 UTC
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)
Comment 1 Max Sauer 2006-09-11 09:28:13 UTC
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
Comment 2 _ tboudreau 2006-09-11 09:43:20 UTC
Created attachment 33748 [details]
Should fix the problem
Comment 3 _ tboudreau 2006-09-11 09:50:39 UTC
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.
Comment 4 _ tboudreau 2006-09-11 09:51:14 UTC
Created attachment 33749 [details]
Sorry, this is the corrected patch
Comment 5 Milos Kleint 2007-01-03 11:37:23 UTC
duplicate of #90745, fixed in trunk.

*** This issue has been marked as a duplicate of 90745 ***