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 121006 - NullPointerException at org.netbeans.modules.search.FindInFilesAction$LookupSensitive$1.run
Summary: NullPointerException at org.netbeans.modules.search.FindInFilesAction$LookupS...
Status: RESOLVED FIXED
Alias: None
Product: utilities
Classification: Unclassified
Component: Search (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Marian Petras
URL: http://statistics.netbeans.org/except...
Keywords: RANDOM, REGRESSION, THREAD
Depends on:
Blocks: 106082
  Show dependency tree
 
Reported: 2007-11-02 17:44 UTC by Jesse Glick
Modified: 2007-12-07 16:41 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter: 10360


Attachments
stacktrace (705 bytes, text/plain)
2007-11-02 17:44 UTC, Jesse Glick
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2007-11-02 17:44:02 UTC
Build: NetBeans IDE Dev (Build 071102)
VM: Java HotSpot(TM) Client VM, 1.5.0_12-b04
OS: Linux, 2.6.22-14-generic, i386

User Comments: 
Just closed a couple of projects.
Comment 1 Jesse Glick 2007-11-02 17:44:11 UTC
Created attachment 52399 [details]
stacktrace
Comment 2 Jesse Glick 2007-11-02 17:56:08 UTC
Looks like a race condition introduced by fix of issue #106082.

I would recommend simplifying code:

private final PropertyChangeSupport support;
LS(...) {
  // ...
  support = new PropertyChangeSupport(this);
  searchScopeRegistry.addChangeListener(WeakListeners.change(this, searchScopeRegistry));
  enabled = searchScopeRegistry.hasApplicableSearchScope();
}
void addPCL(l) {
  support.addPCL(l);
}
void removePCL(l) {
  support.removePCL(l);
}

Besides the race condition, the current code looks like it could be a memory leak anyway, if FIFA.LS.rPCL is never
called for whatever reason.
Comment 3 Marian Petras 2007-11-05 07:24:46 UTC
I will try to fix this for NB 6.0.
Comment 4 Marian Petras 2007-11-14 17:10:19 UTC
Fixed in the trunk.

I did not do the suggested changes because:
a) field 'support' is also used as an indication whether there is some listener registered
b) I am sure FIFA.LS.rPCL is called - the NullPointerException would never be thrown if it was not called

The change I made just changes the code such that when stateChanged() is called, the list of currently registered
listeners is stored and this list is later used for actual notification. This guarantees that the NullPointerException
is never called and that the correct list of listeners is called.

Modified file:
    utilities/src/org/netbeans/modules/search/FindInFilesAction.java   (1.9)

Diff:
http://deadlock.netbeans.org/fisheye/browse/netbeans/utilities/src/org/netbeans/modules/search/FindInFilesAction.java?r1=1.8&r2=1.9