#416 ArrayIndexOutOfBoundsException in DataTypeDouble

2.3rc1
closed-fixed
Core (461)
5
2014-08-04
2006-08-16
Rob Manning
No

I found this when researching bug 1540962 (Editing
double field adds extra decimals). When I change the
value of a field after making table editable as
outlined in the steps of 1540962, and press enter to
accept the value I see the following stack trace:

java.lang.StringIndexOutOfBoundsException: String index
out of range: -1
at java.lang.String.substring(String.java:1768)
at
net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.DataTypeDouble$KeyTextHandler.keyTyped(DataTypeDouble.java:353)
at
java.awt.Component.processKeyEvent(Component.java:5443)
at
javax.swing.JComponent.processKeyEvent(JComponent.java:2713)
at
java.awt.Component.processEvent(Component.java:5265)
at
java.awt.Container.processEvent(Container.java:1966)
at
java.awt.Component.dispatchEventImpl(Component.java:3955)
at
java.awt.Container.dispatchEventImpl(Container.java:2024)
at
java.awt.Component.dispatchEvent(Component.java:3803)
at
java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1810)
at
java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:672)
at
java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:920)
at
java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:798)
at
java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:636)
at
java.awt.Component.dispatchEventImpl(Component.java:3841)
at
java.awt.Container.dispatchEventImpl(Container.java:2024)
at
java.awt.Window.dispatchEventImpl(Window.java:1774)
at
java.awt.Component.dispatchEvent(Component.java:3803)
at
java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at
net.sourceforge.squirrel_sql.client.Application$1.dispatchEvent(Application.java:168)
at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:153)
at java.awt.Dialog$1.run(Dialog.java:515)
at java.awt.Dialog.show(Dialog.java:536)
at
javax.swing.JOptionPane.showOptionDialog(JOptionPane.java:843)
at
javax.swing.JOptionPane.showConfirmDialog(JOptionPane.java:771)
at
javax.swing.JOptionPane.showConfirmDialog(JOptionPane.java:734)
at
net.sourceforge.squirrel_sql.fw.datasetviewer.DataSetViewerEditableTablePanel.changeUnderlyingValueAt(DataSetViewerEditableTablePanel.java:218)
at
net.sourceforge.squirrel_sql.fw.datasetviewer.MyTableModel.setValueAt(MyTableModel.java:164)
at
net.sourceforge.squirrel_sql.fw.gui.SortableTableModel.setValueAt(SortableTableModel.java:135)
at javax.swing.JTable.setValueAt(JTable.java:1925)
at
net.sourceforge.squirrel_sql.fw.datasetviewer.DataSetViewerTablePanel$MyJTable.setValueAt(DataSetViewerTablePanel.java:381)
at
javax.swing.JTable.editingStopped(JTable.java:3338)
at
javax.swing.AbstractCellEditor.fireEditingStopped(AbstractCellEditor.java:124)
at
javax.swing.DefaultCellEditor$EditorDelegate.stopCellEditing(DefaultCellEditor.java:334)
at
javax.swing.DefaultCellEditor.stopCellEditing(DefaultCellEditor.java:219)
at
javax.swing.DefaultCellEditor$EditorDelegate.actionPerformed(DefaultCellEditor.java:351)
at
javax.swing.JTextField.fireActionPerformed(JTextField.java:487)
at
javax.swing.JTextField.postActionEvent(JTextField.java:668)
at
javax.swing.JTextField$NotifyAction.actionPerformed(JTextField.java:783)
at
javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1571)
at
javax.swing.JComponent.processKeyBinding(JComponent.java:2763)
at
javax.swing.JComponent.processKeyBindings(JComponent.java:2798)
at
javax.swing.JComponent.processKeyEvent(JComponent.java:2726)
at
java.awt.Component.processEvent(Component.java:5265)
at
java.awt.Container.processEvent(Container.java:1966)
at
java.awt.Component.dispatchEventImpl(Component.java:3955)
at
java.awt.Container.dispatchEventImpl(Container.java:2024)
at
java.awt.Component.dispatchEvent(Component.java:3803)
at
java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1810)
at
java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:672)
at
java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:920)
at
java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:798)
at
java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:636)
at
java.awt.Component.dispatchEventImpl(Component.java:3841)
at
java.awt.Container.dispatchEventImpl(Container.java:2024)
at
java.awt.Window.dispatchEventImpl(Window.java:1774)
at
java.awt.Component.dispatchEvent(Component.java:3803)
at
java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at
net.sourceforge.squirrel_sql.client.Application$1.dispatchEvent(Application.java:168)
at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.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)

So, it's like the KeyEvent.VK_ENTER has already been
stripped from the text value prior to keyTyped()
in the custom KeyEventListener being called. The
code just assumes this can't happen, by attempting to
use the indexOf value as an index into the array
containing the text value of the text field. I've
fixed this same type of problem in DataTypeBoolean
previously without realizing that this code has
been duplicated throughout the DataType* classes. I
have a JUnit test and code fix to be checked in
very soon.

Rob

Discussion

  • Rob Manning

    Rob Manning - 2006-08-19

    Logged In: YES
    user_id=1287991

    Fixed in CVS.

    Rob

     
  • Rob Manning

    Rob Manning - 2006-08-19
    • status: open --> closed-fixed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks