JDK-5096948 : 1.5.0 Regression: NPE when switching from Metal L&F with JComboBox
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 5.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_nt
  • CPU: x86
  • Submitted: 2004-09-03
  • Updated: 2004-10-25
  • Resolved: 2004-09-22
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
5.0u1 betaFixed 6Fixed
Related Reports
Relates :  
Description
Bug 4864304 made various performance enhancements to Swing. One of the things it did was to allow null for the horizontal scroll bar of a JScrollPane. It then changed BasicComboPopup to set the horizontal scrollbar of the scrollpane to null.

After this fix, when using a JComboBox to switch the look and feel from Metal, a NullPointerException is thrown from MetalScrollPaneUI.uninstallUI (which doesn't check for null). A test case is attached (JSliderTest.java). Run it, and switch to another L&F.

Note: I have another test case which does something similar (ListTest.java), but it isn't affected. I don't know why - could this be timing related?

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.5.0_01 mustang FIXED IN: 1.5.0_01 mustang INTEGRATED IN: 1.5.0_01 mustang
28-09-2004

EVALUATION As Shannon says in the description MetalScrollPaneUI's uninstallUI is not checking for a null horizontal/vertical scrollbar and hence the bug. All other look and feels in all places make sure the horizontal/vertical scrollbars are not null before invoking a method on them. This bug does not happen with ListTest as the popup (containing the scrollpane) is heavyweight and so not reached by way of SwingUtilities.updateComponentTreeUI that is invoked when you change the look and feel. With JSliderTest the popup is lightweight, and so part of the frame and reachable by way SU.updateComponentTreeUI. As part of this change two lines of dead code are being removed from MetalScrollPaneUI. These were found in searching for all calls to get horizontal/vertical scrollbar. ###@###.### 2004-09-08
08-09-2004