JDK-6579129 : REGRESSION:NPE in DefaultTableCellHeaderRenderer in 6u3_b01 due to fix for 6434444
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6u3
  • Priority: P1
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_vista
  • CPU: x86
  • Submitted: 2007-07-11
  • Updated: 2011-03-07
  • Resolved: 2011-03-07
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.
JDK 6 JDK 7
6u4Fixed 7 b20Fixed
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Description
NPE thrown in DefaultTableCellHeaderRenderer while lauching the test in 6u3_b01.
It is working fine with 6u2_b05 and jdk7b15. This is a regression due to fix for 6434444.
This is happening on Vista (Ultimate as well as Enterprise) with default theme.

JDK Info:
=========
java version "1.6.0_03-ea"
Java(TM) SE Runtime Environment (build 1.6.0_03-ea-b01)
Java HotSpot(TM) Client VM (build 1.6.0_03-ea-b01, mixed mode, sharing)

A simple JTable with string data and column names set to its headers, throws an NPE(stack trace attached).
Steps to reproduce: 
1)Run the attached test case with 6u3_b01.
THe UI does not come up and the below exception occurs. 
--------------Exception---------------

Z:\disk11\swing\tmp>c:\jdk1.6.0_03\bin\java -Dswing.defaultlaf=com.sun.java.swin
g.plaf.windows.WindowsLookAndFeel TableSamples
java.lang.reflect.InvocationTargetException
        at java.awt.EventQueue.invokeAndWait(EventQueue.java:997)
        at javax.swing.SwingUtilities.invokeAndWait(SwingUtilities.java:1323)
        at TableSamples.main(TableSamples.java:14)
Caused by: java.lang.NullPointerException
        at sun.swing.table.DefaultTableCellHeaderRenderer.getColumnSortOrder(DefaultTableCellHeaderRenderer.java:104)
        at com.sun.java.swing.plaf.windows.WindowsTableHeaderUI$XPDefaultRenderer.getTableCellRendererComponent(WindowsTableHeaderUI.java:108)
        at javax.swing.plaf.basic.BasicTableHeaderUI.getHeaderRenderer(BasicTableHeaderUI.java:657)
        at javax.swing.plaf.basic.BasicTableHeaderUI.getHeaderHeight(BasicTableHeaderUI.java:692)
        at javax.swing.plaf.basic.BasicTableHeaderUI.createHeaderSize(BasicTableHeaderUI.java:721)
        at javax.swing.plaf.basic.BasicTableHeaderUI.getPreferredSize(BasicTableHeaderUI.java:752)
        at javax.swing.JComponent.getPreferredSize(JComponent.java:1632)
        at javax.swing.ViewportLayout.preferredLayoutSize(ViewportLayout.java:78
)
        at java.awt.Container.preferredSize(Container.java:1616)
        at java.awt.Container.getPreferredSize(Container.java:1601)
        at javax.swing.JComponent.getPreferredSize(JComponent.java:1634)
        at javax.swing.ScrollPaneLayout.layoutContainer(ScrollPaneLayout.java:70
2)
        at java.awt.Container.layout(Container.java:1432)
        at java.awt.Container.doLayout(Container.java:1421)
        at java.awt.Container.validateTree(Container.java:1519)
        at java.awt.Container.validateTree(Container.java:1526)
        at java.awt.Container.validateTree(Container.java:1526)
        at java.awt.Container.validateTree(Container.java:1526)
        at java.awt.Container.validateTree(Container.java:1526)
        at java.awt.Container.validate(Container.java:1491)
        at java.awt.Window.show(Window.java:825)
        at java.awt.Component.show(Component.java:1422)
        at java.awt.Component.setVisible(Component.java:1375)
        at java.awt.Window.setVisible(Window.java:806)
        at TableSamples.createAndShowGUI(TableSamples.java:45)
        at TableSamples.<init>(TableSamples.java:29)
        at TableSamples$1.run(TableSamples.java:18)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)

        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)

        at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
        at sun.swing.table.DefaultTableCellHeaderRenderer.getColumnSortOrder(DefaultTableCellHeaderRenderer.java:104)
        at com.sun.java.swing.plaf.windows.WindowsTableHeaderUI$XPDefaultRenderer.getTableCellRendererComponent(WindowsTableHeaderUI.java:108)
        at javax.swing.plaf.basic.BasicTableHeaderUI.getHeaderRenderer(BasicTableHeaderUI.java:657)
        at javax.swing.plaf.basic.BasicTableHeaderUI.getHeaderHeight(BasicTableHeaderUI.java:692)
        at javax.swing.plaf.basic.BasicTableHeaderUI.createHeaderSize(BasicTableHeaderUI.java:721)
        at javax.swing.plaf.basic.BasicTableHeaderUI.getPreferredSize(BasicTableHeaderUI.java:752)
        at javax.swing.JComponent.getPreferredSize(JComponent.java:1632)
        at javax.swing.ViewportLayout.preferredLayoutSize(ViewportLayout.java:78)
        at java.awt.Container.preferredSize(Container.java:1616)
        at java.awt.Container.getPreferredSize(Container.java:1601)
        at javax.swing.JComponent.getPreferredSize(JComponent.java:1634)
        at javax.swing.ScrollPaneLayout.layoutContainer(ScrollPaneLayout.java:702)
        at java.awt.Container.layout(Container.java:1432)
        at java.awt.Container.doLayout(Container.java:1421)
        at java.awt.Container.validateTree(Container.java:1519)
        at java.awt.Container.validateTree(Container.java:1526)
        at java.awt.Container.validateTree(Container.java:1526)
        at java.awt.Container.validateTree(Container.java:1526)
        at java.awt.Container.validateTree(Container.java:1526)
        at java.awt.Container.validate(Container.java:1491)
        at java.awt.Window.dispatchEventImpl(Window.java:2438)
        at java.awt.Component.dispatchEvent(Component.java:4243)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)

        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)

        at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

--------------Exception---------------

If I uncomment the line table.setAutoCreateRowSorter(true) , the exception does not occur any more.

Comments
EVALUATION DefaultTableCellHeaderRenderer.getColumnSortOrder needs to return null if rowSorter is not defined
17-07-2007

WORK AROUND Setting the setCreateRowSorter property to true and you do not see the exception.
11-07-2007