JDK-4976239 : REGRESSION: JVM crash with NPE exception when run apache Axis tcpmon utility
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 5.0,6
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic,linux,windows_2000
  • CPU: generic,x86
  • Submitted: 2004-01-09
  • Updated: 2005-08-31
  • Resolved: 2005-08-31
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.0u6Fixed 6 b50Fixed
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
###@###.### 2004-01-09

J2SE Version (please include all output from java -version flag):
  java version "1.5.0-beta2"
  Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b32)
  Java HotSpot(TM) Client VM (build 1.5.0-beta2-b32, mixed mode)


Does this problem occur on J2SE 1.3, 1.4 or 1.4.1?  Yes / No (pick one)
 No, it works fine with 1.4.2


Operating System Configuration Information (be specific):
 Windows 2000
 Solaris Sparc

Bug Description:
 When running the Apache Axis tcpmon utility (a Swing based utility), 
 it throws an NullPointerException exception:

C:\>\j2sdk1.5.0\bin\java -classpath c:\axis-1_1rc2\axis-1_1RC2\lib\axis.jar
org.apache.axis.utils.tcpmon
java.lang.NullPointerException
        at org.apache.axis.utils.tcpmon$8.valueChanged(tcpmon.java:1426)
        at
javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSel
ectionModel.java:187)
        at
javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSel
ectionModel.java:167)
        at
javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSel
ectionModel.java:214)
        at
javax.swing.DefaultListSelectionModel.changeSelection(DefaultListSele
ctionModel.java:408)
        at
javax.swing.DefaultListSelectionModel.changeSelection(DefaultListSele
ctionModel.java:417)
        at
javax.swing.DefaultListSelectionModel.removeSelectionIntervalImpl(Def
aultListSelectionModel.java:510)
        at
javax.swing.DefaultListSelectionModel.removeSelectionInterval(Default
ListSelectionModel.java:482)
        at javax.swing.JTable.checkLeadAnchor(JTable.java:2963)
        at javax.swing.JTable.tableRowsInserted(JTable.java:3079)
        at javax.swing.JTable.tableChanged(JTable.java:3013)
        at
javax.swing.table.AbstractTableModel.fireTableChanged(AbstractTableMo
del.java:280)
        at
javax.swing.table.AbstractTableModel.fireTableRowsInserted(AbstractTa
bleModel.java:215)
        at
javax.swing.table.DefaultTableModel.insertRow(DefaultTableModel.java:
349)
        at
javax.swing.table.DefaultTableModel.addRow(DefaultTableModel.java:323
)
        at
javax.swing.table.DefaultTableModel.addRow(DefaultTableModel.java:334
)
        at org.apache.axis.utils.tcpmon$Listener.<init>(tcpmon.java:1474)
        at org.apache.axis.utils.tcpmon$5.actionPerformed(tcpmon.java:431)
        at
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:18
34)
        at
javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.jav
a:2152)
        at
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
.java:420)
        at
javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258
)
        at
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL
istener.java:234)
        at java.awt.Component.processMouseEvent(Component.java:5463)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3052)
        at java.awt.Component.processEvent(Component.java:5228)
        at java.awt.Container.processEvent(Container.java:1961)
        at java.awt.Component.dispatchEventImpl(Component.java:3931)
        at java.awt.Container.dispatchEventImpl(Container.java:2019)
        at java.awt.Component.dispatchEvent(Component.java:3779)
        at
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4203
)
        at
java.awt.LightweightDispatcher.processMouseEvent(Container.java:3883)

        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3813)
        at java.awt.Container.dispatchEventImpl(Container.java:2005)
        at java.awt.Window.dispatchEventImpl(Window.java:1757)
        at java.awt.Component.dispatchEvent(Component.java:3779)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
        at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
read.java:234)
        at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:163)
        at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)

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

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


Steps to Reproduce (be specific):

   1. Start tcpmon by entering the command-line:

      java -classpath axis.jar org.apache.axis.utils.tcpmon

  2. Enter in some values in the fields:
      
      Listen Port# -> 9999
      Target Hostname -> www.cnn.com
      Target Port# -> 80
     
    And click Add.

  3. NPE exception thrown

Comments
EVALUATION This is a regression caused by the fix to 4905083. JTable was modified to ensure that the lead and anchor always make sense. That is, that they're -1 for an empty model, and not -1 for a non-empty model. As this change has broken people, the logic must be removed. However, it has to be done so delicately. Fixing 4905083 also fixed the following list of bugs as a side-effect. 4201917 - shift-click in table with no selection causes exception 4837565 - Selection error by an empty JTable 5050269 - JTable.getSelectedRow() returns 0 for empty table after "tabbing" into the table 4393423 - JTable.getSelectedRow incorrect with empty table, after ENTER is pressed. 4533778 - isSelectionEmpty() returns false in empty JTable 1.3.1, 1.4beta3 4623505 - ArrayIndexOutOfBoundsException due to bad update in DefaultListSelectionModel 4801274 - Tab key selects a non-existent row in an empty JTable 4671612 - JTable reporting invalid selected row count The fix for this bug should avoid causing regressions in any of those bugs. Also, it should avoid regressing the fix for: 5013988 - REGRESSION: Regression-test javax/swing/JTable/ShiftClick/ShiftClick.java fails 5108452 - REGRESSION: JTable needs to clear selection lead & anchor for TableModelEvent And it should fix: 6236783 - JTable constructor calls columnSelectionChanged() As you might guess, this will be a fun one.
16-08-2005

EVALUATION See also 6236783, which reports a similar problem with the same root cause. See also 5013988, which reports another symptom of the fix that caused this. Regression-test javax/swing/JTable/ShiftClick/ShiftClick.java needs to be fixed to work as the final part of fixing this problem.
03-08-2005

CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: dragon mustang
25-09-2004

EVALUATION Reproducible as described with 1.5, not with 1.4.2. I can also reproduce this straight from the command-line before any GUI is displayed: /import/java/jdk1.5/solaris-sparc/bin/java -classpath ./axis-1_1/lib/axis.jar org.apache.axis.utils.tcpmon 9999 www.cnn.com 80 java.lang.NullPointerException at org.apache.axis.utils.tcpmon$8.valueChanged(tcpmon.java:1426) at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:187) at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:167) at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:214) at javax.swing.DefaultListSelectionModel.changeSelection(DefaultListSelectionModel.java:408) at javax.swing.DefaultListSelectionModel.changeSelection(DefaultListSelectionModel.java:417) at javax.swing.DefaultListSelectionModel.removeSelectionIntervalImpl(DefaultListSelectionModel.java:510) at javax.swing.DefaultListSelectionModel.removeSelectionInterval(DefaultListSelectionModel.java:482) at javax.swing.JTable.checkLeadAnchor(JTable.java:2963) at javax.swing.JTable.tableRowsInserted(JTable.java:3079) at javax.swing.JTable.tableChanged(JTable.java:3013) at javax.swing.table.AbstractTableModel.fireTableChanged(AbstractTableModel.java:280) at javax.swing.table.AbstractTableModel.fireTableRowsInserted(AbstractTableModel.java:215) at javax.swing.table.DefaultTableModel.insertRow(DefaultTableModel.java:349) at javax.swing.table.DefaultTableModel.addRow(DefaultTableModel.java:323) at javax.swing.table.DefaultTableModel.addRow(DefaultTableModel.java:334) at org.apache.axis.utils.tcpmon$Listener.<init>(tcpmon.java:1474) at org.apache.axis.utils.tcpmon.<init>(tcpmon.java:1833) at org.apache.axis.utils.tcpmon.main(tcpmon.java:1905) The offending line in tcpmon.java is: int divLoc = outPane.getDividerLocation(); outPane's declaration is: public JSplitPane outPane = null ; For some reason, outPane is not being initialized before events are sent to the ListSelectionListener. I'm still deducing whether this is a bug in Swing or in the Axis tool itself. ###@###.### 2004-02-06 This new behavior is also reproducible with the following, small test case: // Adding a row to a table sends a selection change. import javax.swing.*; import javax.swing.event.*; import javax.swing.table.*; public class Test implements ListSelectionListener { public static void main(String[] args) { JTable table = new JTable(); TableModel model = table.getModel(); table.getSelectionModel().addListSelectionListener(new Test()); ((DefaultTableModel)model).addRow( new Object[] { "---", "---", "---", "---", "---" } ); } public void valueChanged(ListSelectionEvent e) { Thread.dumpStack(); System.out.println("ListSelectionListener.valueChanged()"); } } ###@###.### 2004-02-11 Previous to b32, the test case shows the following stack trace: java.lang.Exception: Stack trace at java.lang.Thread.dumpStack(Thread.java:1079) at Test.valueChanged(Test.java:20) at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:187) at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:167) at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:214) at javax.swing.DefaultListSelectionModel.insertIndexInterval(DefaultListSelectionModel.java:556) at javax.swing.JTable.tableRowsInserted(JTable.java:3019) at javax.swing.JTable.tableChanged(JTable.java:2955) at javax.swing.table.AbstractTableModel.fireTableChanged(AbstractTableModel.java:280) at javax.swing.table.AbstractTableModel.fireTableRowsInserted(AbstractTableModel.java:215) at javax.swing.table.DefaultTableModel.insertRow(DefaultTableModel.java:345) at javax.swing.table.DefaultTableModel.addRow(DefaultTableModel.java:319) at javax.swing.table.DefaultTableModel.addRow(DefaultTableModel.java:330) at Test.main(Test.java:13) ListSelectionListener.valueChanged() ###@###.### 2004-02-18 While this is a change in Swing, such that an event is delivered where it wasn't before, it can be worked around in client code. That is where the NPE appears. This deserves an investigation, but is not a tiger showstopper. ###@###.### 2004-07-15
15-07-2004