Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2013-09-23 13:57:07 +0000
committerEike Stepper2013-09-23 14:55:21 +0000
commiteb20143db914b179ea71c75625d2d82d4c6cb3f4 (patch)
tree5725e9f8b339c30540fb2349e43e686fdec18fe2
parent97e1886dec12db9c7d6e156fe60c140e70d14e5a (diff)
downloadcdo-eb20143db914b179ea71c75625d2d82d4c6cb3f4.tar.gz
cdo-eb20143db914b179ea71c75625d2d82d4c6cb3f4.tar.xz
cdo-eb20143db914b179ea71c75625d2d82d4c6cb3f4.zip
[417825] Invalidator can die if CDOSession can not be activated within
100ms https://bugs.eclipse.org/bugs/show_bug.cgi?id=417825
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_417825_Test.java49
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java30
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/SessionUtil.java60
3 files changed, 113 insertions, 26 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_417825_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_417825_Test.java
new file mode 100644
index 0000000000..0fde7fb58a
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_417825_Test.java
@@ -0,0 +1,49 @@
+/*
+ * 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.tests.AbstractCDOTest;
+
+import org.eclipse.emf.internal.cdo.session.CDOSessionImpl;
+import org.eclipse.emf.internal.cdo.session.SessionUtil;
+
+import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
+
+/**
+ * Bug 417825 - Invalidator can die if CDOSession can not be activated within 100ms.
+ *
+ * @author Eike Stepper
+ */
+public class Bugzilla_417825_Test extends AbstractCDOTest
+{
+ public void testInvalidatorLifecycle() throws Exception
+ {
+ SessionUtil.setTestDelayInSessionActivation(new Runnable()
+ {
+ public void run()
+ {
+ // The session invalidator polls its queue every 100ms, so wait a little longer to see if it died
+ ConcurrencyUtil.sleep(500L);
+ }
+ });
+
+ try
+ {
+ CDOSessionImpl session2 = (CDOSessionImpl)openSession();
+ assertEquals(true, session2.isActive());
+ assertEquals(true, session2.getInvalidator().isActive());
+ }
+ finally
+ {
+ SessionUtil.setTestDelayInSessionActivation(null);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java
index 41712dc907..87ae47be41 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java
@@ -1057,6 +1057,11 @@ public abstract class CDOSessionImpl extends CDOTransactionContainerImpl impleme
invalidator.reorderInvalidations(commitInfo, sender, clearResourcePathCache, permissions);
}
+ public ILifecycle getInvalidator()
+ {
+ return invalidator;
+ }
+
public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter)
{
return Platform.getAdapterManager().getAdapter(this, adapter);
@@ -1249,7 +1254,12 @@ public abstract class CDOSessionImpl extends CDOTransactionContainerImpl impleme
protected void doActivate() throws Exception
{
super.doActivate();
- LifecycleUtil.activate(invalidator);
+
+ Runnable runnable = SessionUtil.getTestDelayInSessionActivation();
+ if (runnable != null)
+ {
+ runnable.run();
+ }
InternalCDORemoteSessionManager remoteSessionManager = new CDORemoteSessionManagerImpl();
remoteSessionManager.setLocalSession(this);
@@ -1261,6 +1271,13 @@ public abstract class CDOSessionImpl extends CDOTransactionContainerImpl impleme
}
@Override
+ protected void doAfterActivate() throws Exception
+ {
+ super.doAfterActivate();
+ LifecycleUtil.activate(invalidator);
+ }
+
+ @Override
protected void doDeactivate() throws Exception
{
LifecycleUtil.deactivate(invalidator);
@@ -1649,6 +1666,8 @@ public abstract class CDOSessionImpl extends CDOTransactionContainerImpl impleme
private final List<Invalidation> reorderQueue = new ArrayList<Invalidation>();
+ private boolean terminateIfSessionClosed;
+
public Invalidator()
{
}
@@ -1726,13 +1745,20 @@ public abstract class CDOSessionImpl extends CDOTransactionContainerImpl impleme
@Override
protected void noWork(WorkContext context)
{
- if (isClosed())
+ if (isClosed() && terminateIfSessionClosed)
{
context.terminate();
}
}
@Override
+ protected void doAfterActivate() throws Exception
+ {
+ super.doAfterActivate();
+ terminateIfSessionClosed = true;
+ }
+
+ @Override
protected String getThreadName()
{
return "CDOSessionInvalidator-" + CDOSessionImpl.this;
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/SessionUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/SessionUtil.java
index 511b6b0029..91abbea2b0 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/SessionUtil.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/SessionUtil.java
@@ -28,32 +28,10 @@ public final class SessionUtil
{
private static final boolean ROOT_RESOURCE_EXCLUSION_CHECK = false;
- private SessionUtil()
- {
- }
+ private static Runnable testDelayInSessionActivation;
- /**
- * @since 2.0
- */
- public static InternalCDOViewSet prepareResourceSet(ResourceSet resourceSet)
+ private SessionUtil()
{
- InternalCDOViewSet viewSet = null;
- synchronized (resourceSet)
- {
- if (ROOT_RESOURCE_EXCLUSION_CHECK)
- {
- addRootResourceExclusionCheckAdapter(resourceSet);
- }
-
- viewSet = (InternalCDOViewSet)CDOUtil.getViewSet(resourceSet);
- if (viewSet == null)
- {
- viewSet = new CDOViewSetImpl();
- resourceSet.eAdapters().add(viewSet);
- }
- }
-
- return viewSet;
}
private static void addRootResourceExclusionCheckAdapter(ResourceSet resourceSet)
@@ -87,4 +65,38 @@ public final class SessionUtil
resourceSet.eAdapters().add(new RootResourceExclusionCheckAdapter());
}
+
+ /**
+ * @since 2.0
+ */
+ public static InternalCDOViewSet prepareResourceSet(ResourceSet resourceSet)
+ {
+ InternalCDOViewSet viewSet = null;
+ synchronized (resourceSet)
+ {
+ if (ROOT_RESOURCE_EXCLUSION_CHECK)
+ {
+ addRootResourceExclusionCheckAdapter(resourceSet);
+ }
+
+ viewSet = (InternalCDOViewSet)CDOUtil.getViewSet(resourceSet);
+ if (viewSet == null)
+ {
+ viewSet = new CDOViewSetImpl();
+ resourceSet.eAdapters().add(viewSet);
+ }
+ }
+
+ return viewSet;
+ }
+
+ public static Runnable getTestDelayInSessionActivation()
+ {
+ return testDelayInSessionActivation;
+ }
+
+ public static void setTestDelayInSessionActivation(Runnable runnable)
+ {
+ testDelayInSessionActivation = runnable;
+ }
}

Back to the top