Issue Details (XML | Word | Printable)

Key: UBA-7624
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Marcel Rüedi
Reporter: Daniel Grob
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
ULCBase

Sorting / modifying an unsorted table with selection may results in an ArrayIndexOutOfBoundsException

Created: 21/Nov/08 08:49 AM   Updated: 09/Jan/09 11:35 AM
Component/s: components
Affects Version/s: None
Fix Version/s: UltraLightClient '08 Update 2


 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Daniel Grob added a comment - 21/Nov/08 09:53 AM
The following snippet reproduces the issue:
import com.ulcjava.base.application.ULCBorderLayoutPane;
import com.ulcjava.base.application.ULCButton;
import com.ulcjava.base.application.ULCFrame;
import com.ulcjava.base.application.ULCScrollPane;
import com.ulcjava.base.application.ULCTable;
import com.ulcjava.base.application.event.ActionEvent;
import com.ulcjava.base.application.event.IActionListener;
import com.ulcjava.base.application.table.DefaultTableModel;
import com.ulcjava.base.development.DevelopmentRunner;
import com.ulcjava.base.shared.internal.ThrowableUtilities;
import com.ulcjava.testframework.development.AbstractSimpleDevelopmentTestCase;
import com.ulcjava.testframework.operator.ULCButtonOperator;
import com.ulcjava.testframework.operator.ULCFrameOperator;
import com.ulcjava.testframework.operator.ULCTableOperator;

public class PR7624Test extends AbstractSimpleDevelopmentTestCase {
    private ULCTable fTable;
    private Throwable fThrowable;
    
    public void start() {
        DefaultTableModel model = new DefaultTableModel(new Object[0][], new String[] {"One"});
        model.addRow(new Object[] {"one"});
        model.addRow(new Object[] {"two"});
        model.addRow(new Object[] {"three"});
        model.addRow(new Object[] {"four"});
        model.addRow(new Object[] {"five"});
        
        fTable = new ULCTable(model);
        fTable.setAutoCreateRowSorter(true);
        
        // it is necessary to alter the model after the row sorter has been attached
        // only then the issue occurs
        model.fireTableDataChanged();
        
        ULCButton removeRow0Button = new ULCButton("Remove Row 0");
        removeRow0Button.addActionListener(new IActionListener() {
            public void actionPerformed(ActionEvent event) {
                DefaultTableModel model = (DefaultTableModel)fTable.getModel();
                try {
                    model.removeRow(0);
                    fail("PR7624Test.start(): remove try catch block");
                } catch (Throwable t) {
                    fThrowable = t;
                }
            }
        });
        
        ULCFrame frame = new ULCFrame("Snippet");
        frame.setDefaultCloseOperation(ULCFrame.TERMINATE_ON_CLOSE);
        frame.getContentPane().add(new ULCScrollPane(fTable));
        frame.getContentPane().add(removeRow0Button, ULCBorderLayoutPane.SOUTH);
        frame.pack();
        frame.setVisible(true);
    }
    
    public void testSnippet() throws InterruptedException {
        ULCFrameOperator frame = new ULCFrameOperator();
        ULCTableOperator table = new ULCTableOperator(frame);
        ULCButtonOperator removeRow0Button = new ULCButtonOperator(frame, "Remove Row 0");
        
        table.selectCell(2, 0);
        removeRow0Button.push();
        
        if (fThrowable != null) {
            System.out.println("PR7624Test.testSnippet(): this should not happen => " + ThrowableUtilities.toString(fThrowable));
        }
    }
    
    public static void main(String[] args) {
        DevelopmentRunner.setApplicationClass(PR7624Test.class);
        DevelopmentRunner.main(args);
    }
}

Marcel Rüedi added a comment - 22/Dec/08 03:13 PM
view to model maps are never set to null