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 177280 - NullPointerException at org.netbeans.swing.dirchooser.DirectoryChooserUI$IconIndenter.getIconWidth
Summary: NullPointerException at org.netbeans.swing.dirchooser.DirectoryChooserUI$Icon...
Status: VERIFIED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Directory Chooser (show other bugs)
Version: 6.x
Hardware: All All
: P1 normal (vote)
Assignee: Stanislav Aubrecht
URL:
Keywords:
: 152315 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-11-20 04:26 UTC by Alexander Simon
Modified: 2009-11-27 03:13 UTC (History)
5 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 146150


Attachments
stacktrace (5.46 KB, text/plain)
2009-11-20 04:26 UTC, Alexander Simon
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Simon 2009-11-20 04:26:52 UTC
Build: NetBeans IDE Dev (Build 091120-1fba373ef266)
VM: Java HotSpot(TM) Client VM, 14.0-b16, Java(TM) SE Runtime Environment, 1.6.0_14-b08
OS: SunOS, 5.10, x86

User Comments:
GUEST: I'm using the Motif Look And Feel.



Stacktrace: 
java.lang.NullPointerException
        at org.netbeans.swing.dirchooser.DirectoryChooserUI$IconIndenter.getIconWidth(DirectoryChooserUI.java:1709)
        at javax.swing.SwingUtilities.layoutCompoundLabelImpl(SwingUtilities.java:946)
        at javax.swing.SwingUtilities.layoutCompoundLabel(SwingUtilities.java:873)
        at javax.swing.plaf.basic.BasicLabelUI.layoutCL(BasicLabelUI.java:72)
        at javax.swing.plaf.basic.BasicLabelUI.getPreferredSize(BasicLabelUI.java:235)
        at javax.swing.JComponent.getPreferredSize(JComponent.java:1634)
Comment 1 Alexander Simon 2009-11-20 04:26:55 UTC
Created attachment 91411 [details]
stacktrace
Comment 2 Alexander Simon 2009-11-20 04:30:19 UTC
cannot open project
Comment 3 David Simonek 2009-11-20 08:57:40 UTC
A complete mystery to me. There used to be this bug, but was fixed in 152315. Currently line 1709 reads:
     return icon != null ? icon.getIconWidth() + depth*space : null;
where depth and space are initialized. It's impossible to have NPE here, so either build was built from different sources or I don't know...

Btw, Alexander Simon, when you just minimize exception window, you should be able to continue and open project, why exactly are you not able to open project?
Comment 4 Alexander Simon 2009-11-20 09:03:45 UTC
I close exception window and open project dialog is not appeared.
When I opening project again the exception window is appeared again....
Comment 5 David Simonek 2009-11-20 09:14:34 UTC
Do you have some older builds to try? Didn't you make some manual changes like copying modules from 6.5 release or anything else that could touch the integrity of the build? I don't have other explanation then that there is different code running in your build then it's in repository sources...
Comment 6 Alexander Simon 2009-11-20 09:23:15 UTC
By the way the code:
    private class IconIndenter implements Icon {
        Icon icon = null;
        public int getIconHeight() {
            return icon != null ? icon.getIconHeight() : null;
        }
   }
is not right.
Should be:
        Icon anIcon = icon;
        return anIcon != null ? anIcon.getIconHeight() : null;
I checked bug on two computers.
Comment 7 Alexander Simon 2009-11-20 09:29:23 UTC
And why you returns null instead 0?
Comment 8 Alexander Simon 2009-11-20 10:04:31 UTC
so right code is:
        Icon anIcon = icon;
        return anIcon != null ? anIcon.getIconHeight() : 0;
Comment 9 David Simonek 2009-11-20 11:35:33 UTC
*** Bug 152315 has been marked as a duplicate of this bug. ***
Comment 10 David Simonek 2009-11-20 11:40:26 UTC
returning null is probably just a typo, fortunately does no harm AFAIK.

Thanks for code review, you mean that icon variable will change from other thread to null after icon != null condition was passed? Yes, that would explain NPE.

I'll integrate your suggestion on Monday, thanks.
Comment 11 Alexander Simon 2009-11-20 11:45:11 UTC
Returning null DOES harm method.
It is equivalent of unboxing:
((Integer)null).intValue();
It is a NPE.
Comment 12 Stanislav Aubrecht 2009-11-23 05:02:32 UTC
fixed in core-main 36f1b0df6e29

QE, pls verify the fix, thanks
Comment 13 Marian Mirilovic 2009-11-23 05:19:01 UTC
verified
Comment 14 Milan Kubec 2009-11-23 06:37:05 UTC
The fix is correct.
Comment 15 Stanislav Aubrecht 2009-11-24 00:54:01 UTC
fixed in release68 clone 91f865ccc985
Comment 16 Quality Engineering 2009-11-24 19:08:19 UTC
Integrated into 'main-golden', will be available in build *200911241400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/36f1b0df6e29
User: S. Aubrecht <saubrecht@netbeans.org>
Log: #177280 - NPE