Bug 157326 - NullPointerException at org.netbeans.modules.ruby.railsprojects.GeneratorPanel.getSelectedGenerator
NullPointerException at org.netbeans.modules.ruby.railsprojects.GeneratorPane...
Status: VERIFIED FIXED
Product: ruby
Classification: Unclassified
Component: Rails
6.x
All All
: P3 (vote)
: 6.x
Assigned To: Erno Mononen
issues@ruby
http://statistics.netbeans.org/except...
EXCEPTIONS_REPORT, 65fixes3-verified
:
: 159584 (view as bug list)
Depends on:
Blocks: 154624
  Show dependency treegraph
 
Reported: 2009-01-22 18:33 UTC by inetufo
Modified: 2009-09-16 02:45 UTC (History)
21 users (show)

See Also:
Issue Type: DEFECT
:


Attachments
stacktrace (1.61 KB, text/plain)
2009-01-22 18:33 UTC, inetufo
Details
stacktrace (1.61 KB, text/plain)
2009-01-22 18:34 UTC, inetufo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description inetufo 2009-01-22 18:33:25 UTC
Build: NetBeans IDE 6.5 (Build 200811100001)
VM: Java HotSpot(TM) Client VM, 11.2-b01, Java(TM) SE Runtime Environment, 1.6.0_12-ea-b03
OS: Windows XP, 5.1, x86

User Comments:
GUEST: When generate, I met java.lang.NullPointerException
	at org.netbeans.modules.ruby.railsprojects.GeneratorPanel.getSelectedGenerator(GeneratorPanel.java:143)
	at org.netbeans.modules.ruby.railsprojects.GeneratorPanel.isValid(GeneratorPanel.java:480)
	at java.awt.Component.invalidateIfValid(Component.java:2711)
	at java.awt.Component.setLocale(Component.java:1780)
	at javax.swing.JComponent.<init>(JComponent.java:600)
	at javax.swing.JPanel.<init>(JPanel.java:82)
	at javax.swing.JPanel.<init>(JPanel.java:109)
	at javax.swing.JPanel.<init>(JPanel.java:117)
	at org.netbeans.modules.ruby.railsprojects.GeneratorPanel.<init>(GeneratorPanel.java:90)
	at org.netbeans.modules.ruby.railsprojects.GenerateAction.generate(GenerateAction.java:174)
	at org.netbeans.modules.ruby.railsprojects.GenerateAction.performAction(GenerateAction.java:153)
	at org.openide.util.actions.NodeAction$DelegateAction$1.run(NodeAction.java:581)
	at org.netbeans.modules.openide.util.ActionsBridge$ActionRunnable.actionPerf

GUEST: generating error



Stacktrace: 
java.lang.NullPointerException
        at org.netbeans.modules.ruby.railsprojects.GeneratorPanel.getSelectedGenerator(GeneratorPanel.java:143)
        at org.netbeans.modules.ruby.railsprojects.GeneratorPanel.isValid(GeneratorPanel.java:480)
        at java.awt.Component.invalidateIfValid(Component.java:2740)
        at java.awt.Component.setLocale(Component.java:1810)
        at javax.swing.JComponent.<init>(JComponent.java:595)
        at javax.swing.JPanel.<init>(JPanel.java:65)
Comment 1 inetufo 2009-01-22 18:33:30 UTC
Created attachment 76148 [details]
stacktrace
Comment 2 inetufo 2009-01-22 18:34:27 UTC
Build: NetBeans IDE 6.5 (Build 200811100001)
VM: Java HotSpot(TM) Client VM, 11.2-b01, Java(TM) SE Runtime Environment, 1.6.0_12-ea-b03
OS: Windows XP, 5.1, x86

User Comments: 


Stacktrace: 
java.lang.NullPointerException
        at org.netbeans.modules.ruby.railsprojects.GeneratorPanel.getSelectedGenerator(GeneratorPanel.java:143)
        at org.netbeans.modules.ruby.railsprojects.GeneratorPanel.isValid(GeneratorPanel.java:480)
        at java.awt.Component.invalidateIfValid(Component.java:2740)
        at java.awt.Component.setLocale(Component.java:1810)
        at javax.swing.JComponent.<init>(JComponent.java:595)
        at javax.swing.JPanel.<init>(JPanel.java:65)
Comment 3 inetufo 2009-01-22 18:34:30 UTC
Created attachment 76149 [details]
stacktrace
Comment 4 Erno Mononen 2009-02-04 13:29:31 UTC
Hopefully fixed now in 02c0e6eeb384. I wasn't able to reproduce, so the fix is a bit of a guess -- please reopen if you 
run into this again. At least it should now fail in a way that gives a better indication of the problem.
Comment 5 Quality Engineering 2009-02-06 07:55:24 UTC
Integrated into 'main-golden', will be available in build *200902060201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/02c0e6eeb384
User: Erno Mononen <emononen@netbeans.org>
Log: #157326: NullPointerException at org.netbeans.modules.ruby.railsprojects.GeneratorPanel.getSelectedGenerator
Comment 6 Exceptions Reporter 2009-02-12 21:43:14 UTC
Reopening - reproduced in NetBeans IDE Dev (Build 200902120201)
http://statistics.netbeans.org/exceptions/detail.do?id=130170
Comment 7 markdavoren 2009-02-12 22:31:21 UTC
I'm not a Java programmer, so take this with a grain of salt.

It looks like getSelectedGenerator is being called before a generator has been selected. In which case
  typeCombo.getSelectedItem() is null
and
  String item = typeCombo.getSelectedItem().toString();
will get a null pointer exception

Looking at the stack trace, get SelectedGenerator is being called, indirectly, by GeneratorPanel's base base class
constructor (JComponent) and hence before the GeneratorPanel object is properly initialized. I don't know if this is
reasonable or not.

I would suggest something like inserting the following before line 143

if (typeCombo.getSelectedItem() == null) {
  return Generator.NONE;
}

though I leave it to the Java experts to suitably optimize this.

Mark.
Comment 8 markdavoren 2009-02-12 23:09:34 UTC
Downgrading from JDK 1.6.0_12 to JDK 1.6.0_07 "fixes" the problem.

I guess somewhere between 7 and 12 the call from the Jcomponent constructor to isValid was added.

Mark.
Comment 9 Erno Mononen 2009-02-13 16:17:16 UTC
Should fixed now in 14bd194a0d50.
Comment 10 Erno Mononen 2009-02-27 06:36:25 UTC
Transplanted to release65_fixes as 2fc6e378a8a2.
Comment 11 Martin Schovanek 2009-02-27 08:15:32 UTC
v.
Comment 12 Erno Mononen 2009-03-04 07:53:38 UTC
*** Issue 159584 has been marked as a duplicate of this issue. ***


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo