Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2013-06-08 04:52:04 -0400
committerEike Stepper2013-06-08 04:52:04 -0400
commit5c155cc29e3b6c3f317a070f07342cc35278b7c8 (patch)
treef355cbbbfbe38e7156feb74ab65782db4d3109b6
parente75494c84f6e5c3ff5bebae9a12a16c992ea61b4 (diff)
downloadcdo-5c155cc29e3b6c3f317a070f07342cc35278b7c8.tar.gz
cdo-5c155cc29e3b6c3f317a070f07342cc35278b7c8.tar.xz
cdo-5c155cc29e3b6c3f317a070f07342cc35278b7c8.zip
[409287] ArrayIndexOutOfBoundsException on rollback
https://bugs.eclipse.org/bugs/show_bug.cgi?id=409287
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_397232_Test.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_409287_Test.java71
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java10
3 files changed, 77 insertions, 6 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_397232_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_397232_Test.java
index bba12fbc30..1f318e8ab1 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_397232_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_397232_Test.java
@@ -59,8 +59,8 @@ public class Bugzilla_397232_Test extends AbstractCDOTest
// Simulate GC
InternalCDOObject cdoObject = (InternalCDOObject)CDOUtil.getCDOObject(g);
- cdoObject.cdoInternalSetState(CDOState.PROXY);
cdoObject.cdoInternalSetRevision(null);
+ cdoObject.cdoInternalSetState(CDOState.PROXY);
// Re-load
g.getDummy();
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_409287_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_409287_Test.java
new file mode 100644
index 0000000000..e908466545
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_409287_Test.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2007-2013 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.CDOState;
+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.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.view.CDOObjectHandler;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.emf.ecore.EReference;
+
+/**
+ * Bug 409287: ArrayIndexOutOfBoundsException on rollback
+ *
+ * @author Jack Lechner
+ */
+public class Bugzilla_409287_Test extends AbstractCDOTest
+{
+ public void testListenersOnRollback() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/test"));
+ Company company = getModel1Factory().createCompany();
+ resource.getContents().add(company);
+ transaction.commit();
+
+ assertEquals(false, transaction.isDirty());
+ assertEquals(false, transaction.hasConflict());
+
+ final Category category = getModel1Factory().createCategory();
+
+ // Add CDO Object handler to mimic placement of regular EMF listeners
+ transaction.addObjectHandler(new CDOObjectHandler()
+ {
+ public void objectStateChanged(CDOView view, CDOObject object, CDOState oldState, CDOState newState)
+ {
+ if (newState.equals(CDOState.TRANSIENT))
+ {
+ try
+ {
+ EReference feature = getModel1Package().getCategory_Categories();
+ category.eIsSet(feature);
+ }
+ catch (ArrayIndexOutOfBoundsException ex)
+ {
+ // Found my exception
+ throw ex;
+ }
+ }
+ }
+ });
+
+ company.getCategories().add(category);
+ transaction.rollback();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java
index da1927660c..21d9f1a5f2 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java
@@ -678,8 +678,8 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
CDOStateMachine.INSTANCE.internalReattach(object, this);
}
- object.cdoInternalSetState(CDOState.DIRTY);
object.cdoInternalSetRevision(goalRevision);
+ object.cdoInternalSetState(CDOState.DIRTY);
revisionChanged = true;
dirtyObjects.put(id, object);
@@ -764,8 +764,8 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
Iterator<CDORevision> revision = revisions.iterator();
for (CDOObject object : conflicts.keySet())
{
- ((InternalCDOObject)object).cdoInternalSetState(state.next());
((InternalCDOObject)object).cdoInternalSetRevision(revision.next());
+ ((InternalCDOObject)object).cdoInternalSetState(state.next());
}
throw WrappedException.wrap(ex);
@@ -1234,8 +1234,6 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
private void removeObject(CDOID id, final CDOObject object)
{
- InternalCDOObject internal = (InternalCDOObject)object;
- internal.cdoInternalSetState(CDOState.TRANSIENT);
removeObject(id);
if (object instanceof CDOResource)
@@ -1252,8 +1250,10 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
});
}
+ InternalCDOObject internal = (InternalCDOObject)object;
internal.cdoInternalSetView(null);
internal.cdoInternalSetID(null);
+ internal.cdoInternalSetState(CDOState.TRANSIENT);
}
private Set<CDOID> rollbackCompletely(CDOUserSavepoint savepoint)
@@ -2188,8 +2188,8 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
{
InternalCDOObject object = newInstance(revision.getEClass());
object.cdoInternalSetRevision(revision);
- object.cdoInternalSetState(CDOState.NEW);
object.cdoInternalSetView(this);
+ object.cdoInternalSetState(CDOState.NEW);
return object;
}

Back to the top