Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2013-06-03 05:49:40 -0400
committerEike Stepper2013-06-03 05:49:40 -0400
commite75494c84f6e5c3ff5bebae9a12a16c992ea61b4 (patch)
treea4e5526db0710cbcb60a7398b0a6878d68df125c
parent905ef22d2f8422ece299560630f4b393ab14a7e4 (diff)
downloadcdo-drops/I20130607-0410.tar.gz
cdo-drops/I20130607-0410.tar.xz
cdo-drops/I20130607-0410.zip
[400128] LifecycleException "Not Active: Transaction X"drops/S20130603-1126drops/I20130607-0410
https://bugs.eclipse.org/bugs/show_bug.cgi?id=400128
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_400128_Test.java92
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java6
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOObjectWrapperBase.java7
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java21
4 files changed, 126 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_400128_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_400128_Test.java
new file mode 100644
index 0000000000..790692ece4
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_400128_Test.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2013 Esteban Dugueperoux (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:
+ * Esteban Dugueperoux - initial API and implementation
+ */
+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.ISessionConfig;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires;
+import org.eclipse.emf.cdo.tests.model4.ContainedElementNoOpposite;
+import org.eclipse.emf.cdo.tests.model4.RefSingleNonContainedNPL;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.util.ECrossReferenceAdapter;
+import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
+
+import java.util.Collections;
+import java.util.Map;
+
+/**
+ * @author Esteban Dugueperoux
+ */
+@Requires(ISessionConfig.CAPABILITY_NET4J_TCP)
+public class Bugzilla_400128_Test extends AbstractCDOTest
+{
+ private static final String RESOURCE_PATH = "cdo.resource";
+
+ private URI xmiURI;
+
+ public void testUnload() throws Exception
+ {
+ Map<String, Object> extensionToFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap();
+ extensionToFactoryMap.put("model1", new XMIResourceFactoryImpl());
+
+ try
+ {
+ initModelWithCrossReferenceFromCDO2XMI();
+
+ ResourceSet resourceSet = new ResourceSetImpl();
+ resourceSet.eAdapters().add(new ECrossReferenceAdapter());
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction(resourceSet);
+ CDOResource cdoResource = transaction.getResource(getResourcePath(RESOURCE_PATH));
+
+ Resource xmiResource = resourceSet.getResource(xmiURI, true);
+
+ cdoResource.cdoView().close(); // Closes the transaction
+ xmiResource.unload();
+ }
+ finally
+ {
+ extensionToFactoryMap.remove("model1");
+ }
+ }
+
+ private void initModelWithCrossReferenceFromCDO2XMI() throws Exception
+ {
+ ResourceSet resourceSet = new ResourceSetImpl();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction(resourceSet);
+ CDOResource cdoResource = transaction.createResource(getResourcePath(RESOURCE_PATH));
+
+ xmiURI = URI.createFileURI(createTempFile("Bugzilla_400128_Test-", ".model1").getCanonicalPath());
+ Resource xmiResource = resourceSet.createResource(xmiURI);
+
+ ContainedElementNoOpposite xmiElement = getModel4Factory().createContainedElementNoOpposite();
+ xmiResource.getContents().add(xmiElement);
+
+ RefSingleNonContainedNPL cdoElement = getModel4Factory().createRefSingleNonContainedNPL();
+ cdoElement.setElement(xmiElement); // Create a cross reference from CDO to XMI
+ cdoResource.getContents().add(cdoElement);
+
+ cdoResource.save(Collections.emptyMap());
+ xmiResource.save(Collections.emptyMap());
+
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java
index 3f39029dc7..a37ddb7f01 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java
@@ -567,6 +567,12 @@ public class CDOObjectImpl extends MinimalEStoreEObjectImpl implements InternalC
@Override
public final Resource.Internal eInternalResource()
{
+ CDOView view = cdoView();
+ if (view != null && view.isClosed())
+ {
+ return null;
+ }
+
if (FSMUtil.isInvalid(this))
{
return null;
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOObjectWrapperBase.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOObjectWrapperBase.java
index 4c2177a3b9..56104d4a44 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOObjectWrapperBase.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOObjectWrapperBase.java
@@ -14,6 +14,7 @@ package org.eclipse.emf.internal.cdo.object;
import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.common.model.EMFUtil;
import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl;
+import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.net4j.util.ReflectUtil;
@@ -320,6 +321,12 @@ public abstract class CDOObjectWrapperBase implements CDOObject, InternalEObject
public Resource.Internal eInternalResource()
{
+ CDOView view = cdoView();
+ if (view != null && view.isClosed())
+ {
+ return null;
+ }
+
return instance.eInternalResource();
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java
index 0c47637346..dc2a1693ac 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java
@@ -1187,6 +1187,27 @@ public class CDOViewImpl extends AbstractCDOView
@Override
protected void doDeactivate() throws Exception
{
+ // TODO A prototype of resource-less object URIs:
+ // try
+ // {
+ // String repositoryUUID = session.getRepositoryInfo().getUUID();
+ // String prefix = CDOURIUtil.PROTOCOL_NAME + "://" + repositoryUUID + "/";
+ // for (Entry<CDOID, InternalCDOObject> entry : getObjects().entrySet())
+ // {
+ // InternalCDOObject object = entry.getValue();
+ // StringBuilder builder = new StringBuilder(prefix);
+ // CDOIDUtil.write(builder, object.cdoID());
+ // URI uri = URI.createURI(builder.toString());
+ // object.eSetProxyURI(uri);
+ // int xxx;
+ // System.out.println(uri);
+ // }
+ // }
+ // catch (Exception ex)
+ // {
+ // OM.LOG.error(ex);
+ // }
+
CDOViewRegistryImpl.INSTANCE.deregister(this);
if (invalidationRunner != null)

Back to the top