Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOSingleValueFeatureDeltaImpl.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_254489_Test.java125
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java7
4 files changed, 135 insertions, 4 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOSingleValueFeatureDeltaImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOSingleValueFeatureDeltaImpl.java
index 38775e6ad4..0225720170 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOSingleValueFeatureDeltaImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOSingleValueFeatureDeltaImpl.java
@@ -76,10 +76,7 @@ public abstract class CDOSingleValueFeatureDeltaImpl extends CDOFeatureDeltaImpl
@Override
public void adjustReferences(CDOReferenceAdjuster referenceAdjuster)
{
- if (newValue instanceof CDOID)
- {
- newValue = referenceAdjuster.adjustReference(newValue);
- }
+ newValue = referenceAdjuster.adjustReference(newValue);
}
public void clear()
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java
index 75b763f68a..5d6589233d 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java
@@ -28,6 +28,7 @@ import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_251544_Test;
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_251752_Test;
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_252214_Test;
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_252909_Test;
+import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_254489_Test;
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
import org.eclipse.emf.cdo.tests.config.impl.ConfigTestSuite;
@@ -94,6 +95,7 @@ public abstract class AllTestsAllConfigs extends ConfigTestSuite
testClasses.add(Bugzilla_251752_Test.class);
testClasses.add(Bugzilla_252214_Test.class);
testClasses.add(Bugzilla_252909_Test.class);
+ testClasses.add(Bugzilla_254489_Test.class);
// TODO testClasses.add(NonCDOResourceTest.class);
// TODO testClasses.add(GeneratedEcoreTest.class);
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_254489_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_254489_Test.java
new file mode 100644
index 0000000000..8f7d9fc40c
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_254489_Test.java
@@ -0,0 +1,125 @@
+/***************************************************************************
+ * Copyright (c) 2008 Eike Stepper, Germany.
+ * 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:
+ * Simon McDuff - initial API and implementation
+ **************************************************************************/
+
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOChangeSubscriptionPolicy;
+import org.eclipse.emf.cdo.CDOSession;
+import org.eclipse.emf.cdo.CDOTransaction;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+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.util.CDOUtil;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.Notifier;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * CDOTransaction.postCommit not adjusting the Transaction/View reference
+ * <p>
+ * See https://bugs.eclipse.org/254489
+ *
+ * @author Simon McDuff
+ */
+public class Bugzilla_254489_Test extends AbstractCDOTest
+{
+
+ public void testBugzilla_254489() throws Exception
+ {
+ msg("Opening session");
+ final CDOSession session = openModel1Session();
+
+ session.setPassiveUpdateEnabled(false);
+
+ // ************************************************************* //
+ msg("Opening transaction");
+ final CDOTransaction transaction1 = session.openTransaction();
+ final CDOTransaction transaction2 = session.openTransaction();
+
+ CDOResource res1 = transaction1.createResource("/res1");
+ final Company companyA1 = getModel1Factory().createCompany();
+ res1.getContents().add(companyA1);
+
+ transaction1.commit();
+
+ transaction2.setChangeSubscriptionPolicy(CDOChangeSubscriptionPolicy.ALL);
+ CDOResource res2 = transaction2.getResource("/res1");
+ Company companyA2 = (Company)res2.getContents().get(0);
+ final TestAdapter companyA2Adapter = new TestAdapter();
+ companyA2.eAdapters().add(companyA2Adapter);
+
+ final Category category1A = getModel1Factory().createCategory();
+ category1A.setName("category1");
+
+ msg("Adding categories");
+ companyA1.getCategories().add(category1A);
+ transaction1.commit();
+
+ msg("Checking after commit");
+ boolean timedOut = new PollingTimeOuter(5, 200)
+ {
+ @Override
+ protected boolean successful()
+ {
+ return companyA2Adapter.getNotifications().size() == 1;
+ }
+ }.timedOut();
+ assertFalse(timedOut);
+
+ Category category2 = (Category)companyA2Adapter.getNotifications().get(0).getNewValue();
+ assertNotSame(category2, category1A);
+ assertSame(transaction2, CDOUtil.getCDOObject(category2).cdoView());
+ }
+
+ /**
+ * @author Simon McDuff
+ */
+ private static class TestAdapter implements Adapter
+ {
+ private List<Notification> notifications = new ArrayList<Notification>();
+
+ private Notifier notifier;
+
+ public TestAdapter()
+ {
+ }
+
+ public Notifier getTarget()
+ {
+ return notifier;
+ }
+
+ public List<Notification> getNotifications()
+ {
+ return notifications;
+ }
+
+ public boolean isAdapterForType(Object type)
+ {
+ return false;
+ }
+
+ public void notifyChanged(Notification notification)
+ {
+ notifications.add(notification);
+ }
+
+ public void setTarget(Notifier newTarget)
+ {
+ notifier = newTarget;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java
index 9da1fdef14..fdf07f55f7 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java
@@ -1134,6 +1134,13 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
{
Set<CDOID> detachedIDs = new HashSet<CDOID>(getDetachedObjects().keySet());
Collection<CDORevisionDelta> deltasCopy = new ArrayList<CDORevisionDelta>(deltas);
+
+ // Adjust references in the deltas. Could be used in ChangeSubscription from others CDOView
+ for (CDORevisionDelta dirtyObjectDelta : deltasCopy)
+ {
+ ((InternalCDORevisionDelta)dirtyObjectDelta).adjustReferences(result.getReferenceAdjuster());
+ }
+
session.handleCommitNotification(timeStamp, dirtyIDs, detachedIDs, deltasCopy, getTransaction());
}

Back to the top