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 117384

Summary: NPE at org.netbeans.modules.options.advanced.AdvancedPanel.update
Product: platform Reporter: emiddio <emiddio>
Component: Options&SettingsAssignee: Yulia Novozhilova <ynov>
Status: RESOLVED FIXED    
Severity: blocker CC: gnewton, jglick, mmirilovic, NBLover1258, persapiens, rboctor
Priority: P2    
Version: 6.x   
Hardware: All   
OS: All   
URL: http://statistics.netbeans.org/exceptions/detail.do?id=5959
Issue Type: DEFECT Exception Reporter: 5959
Attachments: stacktrace
stacktrace
stacktrace
stacktrace
stacktrace
diff for KWalletProvider
Calling init from constructor might be even simpler fix
AdvancedPanelController patch

Description emiddio 2007-10-01 22:32:42 UTC
Build: NetBeans IDE 6.0 Beta 1 (Build 200709141330)
VM: Java HotSpot(TM) Client VM, 1.6.0_02-b06
OS: Windows XP, 5.1, x86

User Comments: 
trying to set options; tools/options
Comment 1 emiddio 2007-10-01 22:32:51 UTC
Created attachment 49941 [details]
stacktrace
Comment 2 rmatous 2007-10-02 10:21:31 UTC
/cvs/core/options/src/org/netbeans/modules/options/OptionsPanel.java,v  <--  OptionsPanel.java
new revision: 1.58; previous revision: 1.57
Comment 3 Lukas Hasik 2007-10-25 16:18:34 UTC
Build: NetBeans IDE Dev (Build 200710240532)
VM: Java HotSpot(TM) Client VM, 1.6.0_03-ea-b02
OS: Windows XP, 5.1, x86

User Comments: 
just Tool >Options>Miscellaneous^J^J-maybe I removed too much clusters from etc/netbeans.clusters ? But the IDE works w/o problems
Comment 4 Lukas Hasik 2007-10-25 16:18:42 UTC
Created attachment 51700 [details]
stacktrace
Comment 5 _ krystyna 2008-04-03 01:34:44 UTC
There are more instances of this since this was closed.
See statistics URL -- in my case (43080), had to restart IDE.
Have not been able to reproduce though.
Comment 6 rahul_maha 2008-04-03 09:56:16 UTC
Build: NetBeans IDE 6.1 Beta (Build 200803050202)
VM: Java HotSpot(TM) Client VM, 1.5.0_12-b04
OS: Windows XP, 5.1, x86

User Comments: 
Comment 7 rahul_maha 2008-04-03 09:56:20 UTC
Created attachment 59601 [details]
stacktrace
Comment 8 cdeblesson 2008-04-07 11:44:16 UTC
Created attachment 59762 [details]
stacktrace
Comment 9 Antonin Nebuzelsky 2008-04-15 17:02:09 UTC
Reassigning to new module owner jskrivanek.
Comment 10 jtanium 2008-05-06 16:05:40 UTC
Build: NetBeans IDE 6.1 (Build 200804211638)
VM: Java HotSpot(TM) Client VM, 10.0-b22, Java(TM) SE Runtime Environment, 1.6.0_06-b02
OS: Linux, 2.6.24-16-generic, i386

User Comments: 
I was viewing the "Advanced Options", then clicked "Basic Options"
Comment 11 jtanium 2008-05-06 16:05:51 UTC
Created attachment 61092 [details]
stacktrace
Comment 12 Jiri Skrivanek 2008-08-02 13:08:33 UTC
This should not happen anymore because Advanced Options were removed from IDE.
Comment 13 Tomas Mysik 2010-11-29 14:40:20 UTC
Happened to me today. P2 because I cannot access Tools > Options > Miscellaneous (I can see only blank panel).

Product Version: NetBeans IDE Dev (Build 101129-e5fa9d201a2b)
Java: 1.6.0_22; Java HotSpot(TM) 64-Bit Server VM 17.1-b03
System: Linux version 2.6.36 running on amd64; UTF-8; cs_CZ (nb)
Comment 14 Yulia Novozhilova 2010-12-13 11:32:26 UTC
Created attachment 104013 [details]
diff for KWalletProvider

This is a patch to fix KWalletProvider. Comments are welcome. Will be integrated in a week.
Comment 15 Yulia Novozhilova 2010-12-13 11:35:13 UTC
Upps, wrong bug number. Attachment was intended for http://netbeans.org/bugzilla/show_bug.cgi?id=186196
Comment 16 Yulia Novozhilova 2011-03-10 15:54:00 UTC
Can't reproduce. Looks like a threading issue but the real cause is not clear yet.  It's too risky to try to fix it close to CF. Will add some debugging info to trunk and wait for the next reproduction on the dev builds to understand the cause of such behaviour.
Comment 17 Jesse Glick 2011-03-11 00:42:12 UTC
Maybe init() has not been called? AdvancedPanelController.getComponent() looks wrong:

        getAdvancedPanel().init();
        return getAdvancedPanel ();

where getAdvancedPanel() is unsynchronized. If it is possible for calls to be made from non-EQ threads, this provides a race condition. Say thread T1 calls getLookup(), which goes into getAdvancedPanel(), sees advancedPanel=null, and starts to create it. Now T2 calls getComponent(), which also sees advancedPanel=null, creates an AdvancedPanel #1, and sets the field to it; getComponent calls init() on AdvancedPanel #1. Now T1 finishes getAdvancedPanel(), sets the advancedPanel field to AdvancedPanel #2, and returns from getLookup(). T2 then calls getAdvancedPanel() again, which is now #2 - uninitialized! - and returns it.

Simplest fix would just be to synchronize getAdvancedPanel(). Another change which would be desirable anyway is to getComponent():

AdvancedPanel p = getAdvancedPanel();
p.init();
return p;


Also, AdvancedPanelController.update() calls getAdvancedPanel().update() without calling init() on it; and AdvancedPanel.update() assumes init() has been called. So if this were called without getComponent() having been called earlier, there would be an NPE. Not sure whether that is possible.
Comment 18 Jaroslav Tulach 2011-03-11 06:53:22 UTC
Created attachment 106900 [details]
Calling init from constructor might be even simpler fix
Comment 19 Jesse Glick 2011-03-11 15:16:55 UTC
(In reply to comment #18)
> Calling init from constructor might be even simpler fix

Would be simpler, though there might be some performance cost to it; I guess the original intent was to avoid creating the (nontrivial) Swing components unless and until the panel is displayed.
Comment 20 Yulia Novozhilova 2011-03-11 16:43:27 UTC
Thank you for the comments. 
Jesse, your guess about calling getLookup() from another thread looks like the right one. I haven't made design of this module out yet but looks like CategoryModel.masterLookupTask could be the place where getAdvancedPanel() is called from non-EQ thread. So attaching the patch you suggested, please take a look.
As for your guess that AdvancedPanelController.update() can be called without getComponent() having been called earlier, it was my first thought so I checked the code carefully. getComponent() is always called earlier than update() method so not the case.
Comment 21 Yulia Novozhilova 2011-03-11 16:44:41 UTC
Created attachment 106916 [details]
AdvancedPanelController patch
Comment 22 Jesse Glick 2011-03-11 16:55:49 UTC
Patch looks right to me.
Comment 23 Yulia Novozhilova 2011-03-11 17:02:17 UTC
So, marking the bug as 70_HR_FIX_CANDIDATE and integrating fix into core-main
Comment 24 Yulia Novozhilova 2011-03-11 17:10:14 UTC
Fix: http://hg.netbeans.org/core-main/rev/6c3fbacf72d3
Comment 25 Yulia Novozhilova 2011-03-11 17:14:42 UTC
Can someone from QA test, please? The best way to test is to open Tools > Options > Miscellaneous in stressful conditions (during building big projects etc.)
Comment 26 Quality Engineering 2011-03-12 09:43:07 UTC
Integrated into 'main-golden', will be available in build *201103120400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/6c3fbacf72d3
User: Yulia Novozhilova <ynov@netbeans.org>
Log: Fix #117384: NPE at org.netbeans.modules.options.advanced.AdvancedPanel.update
Comment 27 Marian Mirilovic 2011-03-14 15:30:51 UTC
I tested it a little bit and was not able to reproduce it in latest dev build.
Comment 28 Petr Cyhelsky 2011-04-07 08:28:26 UTC
I have also tested it on 7.0 RC2 (Build 201104070000) and was unable to reproduce it.