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.
|
|
|
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.
|
|
|
CONVERTED DATA
BugTraq+ Release Management Values
COMMIT TO FIX:
dragon
mustang
|
|
|
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
|
|
|
|