Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEgidijus Vaishnora2011-07-08 10:19:50 +0000
committerEgidijus Vaishnora2011-07-08 10:19:50 +0000
commita4a75cb10703c987fcfc583eddc1607717508c0b (patch)
treec88e8da349ca175a4d187162999d80fcfdf5dc32
parentb8d2207c00f11ae8315c44285684ccdb376cee2d (diff)
downloadcdo-a4a75cb10703c987fcfc583eddc1607717508c0b.tar.gz
cdo-a4a75cb10703c987fcfc583eddc1607717508c0b.tar.xz
cdo-a4a75cb10703c987fcfc583eddc1607717508c0b.zip
351198: Session is not invalidated after commit
https://bugs.eclipse.org/bugs/show_bug.cgi?id=351198
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_351198_Test.java156
2 files changed, 157 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java
index 6445ce3532..250f2ea4a6 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java
@@ -229,5 +229,6 @@ public abstract class AllConfigs extends ConfigTestSuite
testClasses.add(Bugzilla_343332_Test.class);
testClasses.add(Bugzilla_343471_Test.class);
testClasses.add(Bugzilla_351195_Test.class);
+ testClasses.add(Bugzilla_351198_Test.class);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_351198_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_351198_Test.java
new file mode 100644
index 0000000000..314afbc848
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_351198_Test.java
@@ -0,0 +1,156 @@
+/**
+ * Copyright (c) 2004 - 2011 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.CDOLock;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.server.IRepository.WriteAccessHandler;
+import org.eclipse.emf.cdo.server.IStoreAccessor.CommitContext;
+import org.eclipse.emf.cdo.server.ITransaction;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.session.CDOSessionInvalidationEvent;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.event.IListener;
+import org.eclipse.net4j.util.om.monitor.OMMonitor;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+/**
+ * @author Egidijus Vaisnora
+ */
+public class Bugzilla_351198_Test extends AbstractCDOTest
+{
+ public void testInvalidation() throws CommitException, InterruptedException
+ {
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction1 = session.openTransaction();
+
+ transaction1.createResource(getResourcePath("test"));
+ transaction1.commit();
+
+ Failure handler = new Failure();
+ getRepository().addHandler(handler);
+ CDOTransaction failureTransaction = session.openTransaction();
+ failureTransaction.createResource(getResourcePath("fail"));
+
+ try
+ {
+ // Creating failure commit. It will change last update time on server TimeStampAuthority
+ failureTransaction.commit();
+ fail("CommitException expected");
+ }
+ catch (CommitException expected)
+ {
+ }
+
+ getRepository().removeHandler(handler);
+ session.close();
+ }
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ final CountDownLatch invalidationLatch = new CountDownLatch(1);
+ session.addListener(new IListener()
+ {
+ public void notifyEvent(IEvent event)
+ {
+ if (event instanceof CDOSessionInvalidationEvent)
+ {
+ invalidationLatch.countDown();
+ }
+ }
+ });
+
+ Company createCompany = getModel1Factory().createCompany();
+ CDOResource resource = transaction.getResource(getResourcePath("test"));
+ resource.getContents().add(createCompany);
+
+ // Invalidation shall fail, because it will use lastUpdateTime from TimeStampAuthority for commit result
+ transaction.commit();
+
+ invalidationLatch.await(500, TimeUnit.MILLISECONDS);
+ assertEquals("Invalidation was not delivered", 0, invalidationLatch.getCount());
+ }
+
+ public void testDeadlockWithLocking() throws CommitException, InterruptedException, TimeoutException
+ {
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction1 = session.openTransaction();
+
+ transaction1.createResource(getResourcePath("test"));
+ transaction1.commit();
+
+ Failure handler = new Failure();
+ getRepository().addHandler(handler);
+
+ CDOTransaction failureTransaction = session.openTransaction();
+ failureTransaction.createResource(getResourcePath("fail"));
+
+ try
+ {
+ // Creating failure commit. It will change last update time on server TimeStampAuthority
+ failureTransaction.commit();
+ fail("CommitException expected");
+ }
+ catch (CommitException expected)
+ {
+ }
+
+ getRepository().removeHandler(handler);
+ session.close();
+ }
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOTransaction updaterTransaction = session.openTransaction();
+
+ CDOResource resourceOnUpdater = updaterTransaction.getResource(getResourcePath("test"));
+ // Resolve PROXY state
+ resourceOnUpdater.getName();
+
+ Company createCompany = getModel1Factory().createCompany();
+ CDOResource resource = transaction.getResource(getResourcePath("test"));
+ resource.getContents().add(createCompany);
+ // Invalidation shall fail, because it will use lastUpdateTime from TimeStampAuthority for commit result
+ transaction.commit();
+
+ CDOLock cdoWriteLock = resourceOnUpdater.cdoWriteLock();
+ // Waiting for commit which already happen
+ cdoWriteLock.lock(1000);
+ }
+
+ /**
+ * @author Egidijus Vaisnora
+ */
+ private class Failure implements WriteAccessHandler
+ {
+ public void handleTransactionBeforeCommitting(ITransaction transaction, CommitContext commitContext,
+ OMMonitor monitor) throws RuntimeException
+ {
+ throw new IllegalArgumentException("Fail on purpose");
+ }
+
+ public void handleTransactionAfterCommitted(ITransaction transaction, CommitContext commitContext, OMMonitor monitor)
+ {
+ // Do nothing
+ }
+ }
+} \ No newline at end of file

Back to the top