From efd9c22e7d5b95bae22679b828e5ac432cfa3255 Mon Sep 17 00:00:00 2001 From: Stefan Winkler Date: Thu, 10 Jan 2013 15:58:05 +0100 Subject: ASSIGNED - bug 390283: [DB] Incorrect handling of operations on unordered ELists https://bugs.eclipse.org/bugs/show_bug.cgi?id=390283 --- .../db/mapping/horizontal/AuditListTableMappingWithRanges.java | 8 +++++++- .../mapping/horizontal/BranchingListTableMappingWithRanges.java | 8 +++++++- .../org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_390283_Test.java | 2 -- 3 files changed, 14 insertions(+), 4 deletions(-) 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 7a3e49ba56..22364ac71d 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 @@ public class AuditListTableMappingWithRanges extends BasicAbstractListTableMappi 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 @@ public class AuditListTableMappingWithRanges extends BasicAbstractListTableMappi 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 1a3838f11c..4cc3ecde1e 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 @@ public class BranchingListTableMappingWithRanges extends BasicAbstractListTableM 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 @@ public class BranchingListTableMappingWithRanges extends BasicAbstractListTableM 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 50414690c1..81049c2991 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 @@ package org.eclipse.emf.cdo.tests.bugzilla; 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 @@ import java.util.Arrays; * * @author Eike Stepper */ -@Skips("DB.ranges") public class Bugzilla_390283_Test extends AbstractCDOTest { public void testAddAfterRemove() throws Exception -- cgit v1.2.3