ASSIGNED - bug 390283: [DB] Incorrect handling of operations on
unordered ELists
https://bugs.eclipse.org/bugs/show_bug.cgi?id=390283
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMappingWithRanges.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMappingWithRanges.java
index 7a3e49b..22364ac 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMappingWithRanges.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMappingWithRanges.java
@@ -603,7 +603,7 @@
int toIdx = delta.getNewPosition();
// optimization: a move from the end of the list to an index that was just removed requires no shifting
- boolean optimizeMove = lastRemovedIndex != -1 && fromIdx == lastIndex && toIdx == lastRemovedIndex;
+ boolean optimizeMove = lastRemovedIndex != -1 && fromIdx == lastIndex - 1 && toIdx == lastRemovedIndex;
if (TRACER.isEnabled())
{
@@ -637,6 +637,12 @@
moveOneDown(accessor, id, oldVersion, newVersion, toIdx, fromIdx - 1);
}
}
+ else
+ {
+ // finish the optimized move by resetting lastRemovedIndex
+ lastRemovedIndex = -1;
+ --lastIndex;
+ }
// create the item
addEntry(accessor, id, newVersion, toIdx, value);
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java
index 1a3838f..4cc3ecd 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java
@@ -878,7 +878,7 @@
int toIdx = delta.getNewPosition();
// optimization: a move from the end of the list to an index that was just removed requires no shifting
- boolean optimizeMove = lastRemovedIndex != -1 && fromIdx == lastIndex && toIdx == lastRemovedIndex;
+ boolean optimizeMove = lastRemovedIndex != -1 && fromIdx == lastIndex - 1 && toIdx == lastRemovedIndex;
if (TRACER.isEnabled())
{
@@ -912,6 +912,12 @@
moveOneDown(accessor, id, branchID, oldVersion, newVersion, toIdx, fromIdx - 1);
}
}
+ else
+ {
+ // finish the optimized move by resetting lastRemovedIndex
+ lastRemovedIndex = -1;
+ --lastIndex;
+ }
// create the item
addEntry(accessor, id, branchID, newVersion, toIdx, value);
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_390283_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_390283_Test.java
index 5041469..81049c2 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_390283_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_390283_Test.java
@@ -13,7 +13,6 @@
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.tests.AbstractCDOTest;
-import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Skips;
import org.eclipse.emf.cdo.tests.model6.UnorderedList;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
@@ -26,7 +25,6 @@
*
* @author Eike Stepper
*/
-@Skips("DB.ranges")
public class Bugzilla_390283_Test extends AbstractCDOTest
{
public void testAddAfterRemove() throws Exception