JDK-6735259 : NPE at WindowsComboBoxUI$XPComboBoxButton.getState(WindowsComboBoxUI.java:408)
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6u10
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2008-08-08
  • Updated: 2011-01-19
  • Resolved: 2008-12-03
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other JDK 6 JDK 7
5.0u19Fixed 6u12 b02Fixed 7Fixed
When using NetBeans on Win platform with JDK 1.6.0_10, NetBeans users reported they got
following NPE from time to time:

        at com.sun.java.swing.plaf.windows.WindowsComboBoxUI$XPComboBoxButton.getState(WindowsComboBoxUI.java:408)
        at com.sun.java.swing.plaf.windows.XPStyle$GlyphButton.paintComponent(XPStyle.java:717)
        at javax.swing.JComponent.paint(JComponent.java:1027)
        at javax.swing.JComponent.paintChildren(JComponent.java:864)
        at javax.swing.JComponent.paint(JComponent.java:1036)
        at javax.swing.JComponent.paintChildren(JComponent.java:864)

Unfortunately, issue is random so I can't give you fully reproducible steps. But by looking at NetBeans exception reporter results: http://statistics.netbeans.org/analytics/detail.do?id=11541 we can see that issue is relatively frequent for NetBeans users (already 20 duplicates)

Just suggestion - maybe blind null check would be enough to fix this issue?
I forgot to mention exact JDK build for exception, here it comes:

VM: Java HotSpot(TM) Client VM, 11.0-b11, Java(TM) SE Runtime Environment, 1.6.0_10-beta-b20
OS: Windows XP, 5.1, x86

Original bug filed in NetBeans IZ: http://www.netbeans.org/issues/show_bug.cgi?id=141853

EVALUATION I coundn't make a test case to reproduce this bug, anyway it worth fixing, because the fix is safe and very anticipated by Netbeans

EVALUATION It looks like a threading problem in the Netbeans code, but to be on the safe side we can add a null check for the comboBox field