ref #7614 Fix possible IndexOutOfBoundException
authorPatrick Plitzner <p.plitzner@bgbm.org>
Fri, 3 Aug 2018 07:08:12 +0000 (09:08 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Fri, 3 Aug 2018 07:08:12 +0000 (09:08 +0200)
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorE4Composite.java

index a053fc50c5bf4d65551169ed5a17b02cc9423b43..06b6db4088ac8488314ba0f2bbf8db0568017e82 100644 (file)
@@ -341,7 +341,14 @@ public class BulkEditorE4Composite extends Composite {
         List<CdmBase> selection = new ArrayList<>();
         int[] fullySelectedRowPositions = bodyLayer.getSelectionLayer().getFullySelectedRowPositions();
         for (int i : fullySelectedRowPositions) {
-            Object rowObject = bodyDataProvider.getRowObject(i);
+            /*
+             * Differentiation between "index" and "position" is important here
+             * "position" is the current visible index "index" refers to the
+             * underlying data model deleting an entity could lead to an
+             * IndexOutOfBoundExceptions if the position is used
+             */
+            int rowIndexByPosition = natTable.getRowIndexByPosition(i);
+            Object rowObject = bodyDataProvider.getRowObject(rowIndexByPosition);
             if(rowObject instanceof CdmBase){
                 selection.add((CdmBase) rowObject);
             }