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

Summary: NullPointerException at org.netbeans.modules.search.FindInFilesAction$LookupSensitive$1.run
Product: utilities Reporter: Jesse Glick <jglick>
Component: SearchAssignee: Marian Petras <mpetras>
Status: RESOLVED FIXED    
Severity: blocker Keywords: RANDOM, REGRESSION, THREAD
Priority: P3    
Version: 6.x   
Hardware: All   
OS: All   
URL: http://statistics.netbeans.org/exceptions/detail.do?id=10360
Issue Type: DEFECT Exception Reporter: 10360
Bug Depends on:    
Bug Blocks: 106082    
Attachments: stacktrace

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