Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2016-01-08 11:11:24 +0000
committerEike Stepper2016-01-08 11:11:24 +0000
commit3a3450b0674c078900bd1373ea075e040516c425 (patch)
tree934fb9bf2931eeb478ab88b6d12008a22f59c47b
parent434699e1111993866a556d2fbd6e80680484372c (diff)
downloadcdo-3a3450b0674c078900bd1373ea075e040516c425.tar.gz
cdo-3a3450b0674c078900bd1373ea075e040516c425.tar.xz
cdo-3a3450b0674c078900bd1373ea075e040516c425.zip
[485394] Referential integrity check does not detect stale containment proxies
https://bugs.eclipse.org/bugs/show_bug.cgi?id=485394
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/XRefsQueryHandler.java40
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_485394_Test.java73
2 files changed, 100 insertions, 13 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/XRefsQueryHandler.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/XRefsQueryHandler.java
index a4e5bd664b..65a2ee7bde 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/XRefsQueryHandler.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/XRefsQueryHandler.java
@@ -160,22 +160,36 @@ public class XRefsQueryHandler implements IQueryHandler
public static void collectSourceCandidates(EClass eClass, EReference eReference, Collection<EClass> concreteTypes,
Map<EClass, List<EReference>> sourceCandidates)
{
- if (!eClass.isAbstract() && !eClass.isInterface())
+ if (eClass.isAbstract())
{
- if (!eReference.isContainer() && !eReference.isContainment())
- {
- if (canReference(eReference.getEReferenceType(), concreteTypes))
- {
- List<EReference> list = sourceCandidates.get(eClass);
- if (list == null)
- {
- list = new ArrayList<EReference>();
- sourceCandidates.put(eClass, list);
- }
+ return;
+ }
- list.add(eReference);
- }
+ if (eClass.isInterface())
+ {
+ return;
+ }
+
+ if (eReference.isContainer())
+ {
+ return;
+ }
+
+ if (eReference.isContainment() && !eReference.isResolveProxies())
+ {
+ return;
+ }
+
+ if (canReference(eReference.getEReferenceType(), concreteTypes))
+ {
+ List<EReference> list = sourceCandidates.get(eClass);
+ if (list == null)
+ {
+ list = new ArrayList<EReference>();
+ sourceCandidates.put(eClass, list);
}
+
+ list.add(eReference);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_485394_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_485394_Test.java
new file mode 100644
index 0000000000..626410cc73
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_485394_Test.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2016 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.eresource.CDOResource;
+import org.eclipse.emf.cdo.server.IRepository;
+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.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.ReferentialIntegrityException;
+
+import java.util.Map;
+
+/**
+ * Bug 485394: Referential integrity check does not detect stale containment proxies
+ *
+ * @author Eike Stepper
+ */
+public class Bugzilla_485394_Test extends AbstractCDOTest
+{
+ @Override
+ public synchronized Map<String, Object> getTestProperties()
+ {
+ Map<String, Object> map = super.getTestProperties();
+ map.put(IRepository.Props.ENSURE_REFERENTIAL_INTEGRITY, "true");
+ return map;
+ }
+
+ public void testReferentialIntegrityWithContainmentProxy() throws Exception
+ {
+ skipStoreWithoutQueryXRefs();
+ disableConsole();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource1 = transaction.createResource(getResourcePath("/test1"));
+ CDOResource resource2 = transaction.createResource(getResourcePath("/test2"));
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("Company");
+ resource1.getContents().add(company);
+
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName("Customer");
+ company.getCustomers().add(customer);
+
+ // Create the cross-resource containment proxy.
+ resource2.getContents().add(customer);
+ transaction.commit();
+
+ resource2.delete(null);
+
+ try
+ {
+ transaction.commit();
+ fail("ReferentialIntegrityException expected");
+ }
+ catch (ReferentialIntegrityException expected)
+ {
+ // SUCCESS
+ }
+ }
+}

Back to the top