Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2013-10-20 00:01:03 -0400
committerEike Stepper2013-10-20 00:01:03 -0400
commit89401a02e4655f50121d7cc275066731621776dc (patch)
treed5b159dd4c4eb6a5e8a9da05d13d1a098627b38e
parent818bb91c31a41509583a81ebe37439c187ea5cfd (diff)
downloadcdo-89401a02e4655f50121d7cc275066731621776dc.tar.gz
cdo-89401a02e4655f50121d7cc275066731621776dc.tar.xz
cdo-89401a02e4655f50121d7cc275066731621776dc.zip
[419574] NPE in CDOMergingConflictResolver
https://bugs.eclipse.org/bugs/show_bug.cgi?id=419574
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_419574_Test.java82
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyWrapper.java8
2 files changed, 89 insertions, 1 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_419574_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_419574_Test.java
new file mode 100644
index 0000000000..d855a20443
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_419574_Test.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 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.common.CDOCommonSession.Options.PassiveUpdateMode;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.model1.Customer;
+import org.eclipse.emf.cdo.tests.model1.SalesOrder;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.emf.spi.cdo.CDOMergingConflictResolver;
+
+/**
+ * Bug 419574 - NPE in CDOMergingConflictResolver.
+ *
+ * @author Eike Stepper
+ */
+public class Bugzilla_419574_Test extends AbstractCDOTest
+{
+ public void testConflict() throws Exception
+ {
+ String resourcePath = getResourcePath("/res1");
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("Central");
+
+ transaction.createResource(resourcePath).getContents().add(company);
+ transaction.commit();
+ session.close();
+ }
+
+ CDOSession session1 = openSession();
+ session1.options().setPassiveUpdateMode(PassiveUpdateMode.CHANGES);
+
+ CDOSession session2 = openSession();
+ session2.options().setPassiveUpdateMode(PassiveUpdateMode.CHANGES);
+
+ CDOTransaction transaction1 = session1.openTransaction();
+ transaction1.options().addConflictResolver(new CDOMergingConflictResolver());
+ // transaction1.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+
+ CDOTransaction transaction2 = session2.openTransaction();
+ transaction2.options().addConflictResolver(new CDOMergingConflictResolver());
+ // transaction2.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
+
+ Company company1 = (Company)transaction1.getResource(resourcePath).getContents().get(0);
+ Customer c1 = getModel1Factory().createCustomer();
+ company1.getCustomers().add(c1);
+
+ Company company2 = (Company)transaction2.getResource(resourcePath).getContents().get(0);
+ Customer c2 = getModel1Factory().createCustomer();
+ company2.getCustomers().add(c2);
+
+ commitAndSync(transaction1, transaction2);
+ commitAndSync(transaction2, transaction1);
+
+ SalesOrder s1 = getModel1Factory().createSalesOrder();
+ s1.setCustomer(c1);
+ company1.getSalesOrders().add(s1);
+
+ SalesOrder s2 = getModel1Factory().createSalesOrder();
+ s2.setCustomer(c2);
+ company2.getSalesOrders().add(s2);
+
+ commitAndSync(transaction1, transaction2);
+ commitAndSync(transaction2, transaction1);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyWrapper.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyWrapper.java
index 8d9c36debe..25a3545eda 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyWrapper.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyWrapper.java
@@ -202,7 +202,13 @@ public abstract class CDOLegacyWrapper extends CDOObjectWrapper
public CDOPermission cdoPermission()
{
- return cdoRevision(true).getPermission();
+ InternalCDORevision revision = cdoRevision(true);
+ if (revision == null)
+ {
+ return CDOPermission.WRITE;
+ }
+
+ return revision.getPermission();
}
@Override

Back to the top