Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2013-09-23 11:54:34 -0400
committerEike Stepper2013-09-23 11:54:34 -0400
commit53683da234edff709a27bbfc6beaa1a9c9065278 (patch)
treecc0505a87ceba5f798ac755e9d964504d5f663fa
parenteb20143db914b179ea71c75625d2d82d4c6cb3f4 (diff)
downloadcdo-53683da234edff709a27bbfc6beaa1a9c9065278.tar.gz
cdo-53683da234edff709a27bbfc6beaa1a9c9065278.tar.xz
cdo-53683da234edff709a27bbfc6beaa1a9c9065278.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_417844_Test.java63
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOViewContainerImpl.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/SessionUtil.java12
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java55
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/QueueWorker.java20
5 files changed, 96 insertions, 56 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_417844_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_417844_Test.java
new file mode 100644
index 0000000000..9e76acf813
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_417844_Test.java
@@ -0,0 +1,63 @@
+/*
+ * 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.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.emf.internal.cdo.session.SessionUtil;
+import org.eclipse.emf.internal.cdo.view.CDOViewImpl;
+
+import org.eclipse.net4j.util.WrappedException;
+import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
+
+/**
+ * Bug 417844 - InvalidationRunner can die if invalidations come too early.
+ *
+ * @author Eike Stepper
+ */
+public class Bugzilla_417844_Test extends AbstractCDOTest
+{
+ public void testInvalidationRunnerLifecycle() throws Exception
+ {
+ CDOSession session = openSession();
+ final CDOTransaction transaction = session.openTransaction();
+ transaction.createResource(getResourcePath("res1"));
+
+ SessionUtil.setTestDelayInViewActivation(new Runnable()
+ {
+ public void run()
+ {
+ try
+ {
+ transaction.commit(); // Trigger invalidation of the view below
+ ConcurrencyUtil.sleep(500L);
+ }
+ catch (Exception ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+ }
+ });
+
+ try
+ {
+ CDOViewImpl view = (CDOViewImpl)session.openView();
+ assertEquals(true, view.isActive());
+ assertEquals(true, view.getInvalidationRunner().isActive());
+ }
+ finally
+ {
+ SessionUtil.setTestDelayInViewActivation(null);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOViewContainerImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOViewContainerImpl.java
index 4a2bdc4c3c..4069a54d94 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOViewContainerImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOViewContainerImpl.java
@@ -252,7 +252,7 @@ public abstract class CDOViewContainerImpl extends Container<CDOView> implements
{
view.setViewID(++lastViewID);
initViewSynced(view);
- views.add(view);
+ views.add(view); // From now the view.invalidate() method can be called!
}
// Link ViewSet with View
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 91abbea2b0..49ce1fb960 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
@@ -30,6 +30,8 @@ public final class SessionUtil
private static Runnable testDelayInSessionActivation;
+ private static Runnable testDelayInViewActivation;
+
private SessionUtil()
{
}
@@ -99,4 +101,14 @@ public final class SessionUtil
{
testDelayInSessionActivation = runnable;
}
+
+ public static Runnable getTestDelayInViewActivation()
+ {
+ return testDelayInViewActivation;
+ }
+
+ public static void setTestDelayInViewActivation(Runnable runnable)
+ {
+ testDelayInViewActivation = runnable;
+ }
}
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 5a9c8e5f1a..b221787113 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
@@ -57,10 +57,10 @@ import org.eclipse.emf.internal.cdo.messages.Messages;
import org.eclipse.emf.internal.cdo.object.CDODeltaNotificationImpl;
import org.eclipse.emf.internal.cdo.object.CDOInvalidationNotificationImpl;
import org.eclipse.emf.internal.cdo.object.CDONotificationBuilder;
+import org.eclipse.emf.internal.cdo.session.SessionUtil;
import org.eclipse.emf.internal.cdo.util.DefaultLocksChangedEvent;
import org.eclipse.net4j.util.ObjectUtil;
-import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump;
import org.eclipse.net4j.util.WrappedException;
import org.eclipse.net4j.util.collection.HashBag;
import org.eclipse.net4j.util.collection.Pair;
@@ -131,10 +131,7 @@ public class CDOViewImpl extends AbstractCDOView
private Map<CDOObject, CDOLockState> lockStates = new WeakHashMap<CDOObject, CDOLockState>();
- private QueueRunner invalidationRunner;
-
- @ExcludeFromDump
- private InvalidationRunnerLock invalidationRunnerLock = new InvalidationRunnerLock();
+ private QueueRunner invalidationRunner = createInvalidationRunner();
private volatile boolean invalidationRunnerActive;
@@ -899,26 +896,18 @@ public class CDOViewImpl extends AbstractCDOView
}
}
- private QueueRunner getInvalidationRunner()
+ public QueueRunner getInvalidationRunner()
{
- synchronized (invalidationRunnerLock)
+ try
+ {
+ invalidationRunner.activate();
+ }
+ catch (LifecycleException ex)
{
- if (invalidationRunner == null)
+ // Don't pollute the log if the worker thread is interrupted due to asynchronous view.close()
+ if (!(ex.getCause() instanceof InterruptedException))
{
- invalidationRunner = createInvalidationRunner();
-
- try
- {
- invalidationRunner.activate();
- }
- catch (LifecycleException ex)
- {
- // Don't pollute the log if the worker thread is interrupted due to asynchronous view.close()
- if (!(ex.getCause() instanceof InterruptedException))
- {
- throw ex;
- }
- }
+ throw ex;
}
}
@@ -1185,6 +1174,12 @@ public class CDOViewImpl extends AbstractCDOView
}
CDOViewRegistryImpl.INSTANCE.register(this);
+
+ Runnable runnable = SessionUtil.getTestDelayInViewActivation();
+ if (runnable != null)
+ {
+ runnable.run();
+ }
}
@Override
@@ -1225,12 +1220,7 @@ public class CDOViewImpl extends AbstractCDOView
// }
CDOViewRegistryImpl.INSTANCE.deregister(this);
-
- if (invalidationRunner != null)
- {
- LifecycleUtil.deactivate(invalidationRunner, OMLogger.Level.WARN);
- invalidationRunner = null;
- }
+ LifecycleUtil.deactivate(invalidationRunner, OMLogger.Level.WARN);
try
{
@@ -1683,15 +1673,6 @@ public class CDOViewImpl extends AbstractCDOView
}
/**
- * A separate class for better monitor debugging.
- *
- * @author Eike Stepper
- */
- private static final class InvalidationRunnerLock
- {
- }
-
- /**
* @author Eike Stepper
*/
private final class InvalidationRunnable implements Runnable
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/QueueWorker.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/QueueWorker.java
index 6aa5dc3b62..66b7ef1ef2 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/QueueWorker.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/QueueWorker.java
@@ -27,7 +27,7 @@ public abstract class QueueWorker<E> extends Worker
*/
public static final int DEFAULT_POLL_MILLIS = 100;
- private BlockingQueue<E> queue;
+ private BlockingQueue<E> queue = createQueue();
private long pollMillis;
@@ -70,14 +70,7 @@ public abstract class QueueWorker<E> extends Worker
@Override
protected void work(WorkContext context) throws Exception
{
- if (queue == null)
- {
- context.terminate();
- }
- else
- {
- doWork(context);
- }
+ doWork(context);
}
private void doWork(WorkContext context) throws InterruptedException
@@ -124,13 +117,6 @@ public abstract class QueueWorker<E> extends Worker
}
@Override
- protected void doActivate() throws Exception
- {
- queue = createQueue();
- super.doActivate();
- }
-
- @Override
protected void doDeactivate() throws Exception
{
super.doDeactivate();
@@ -148,8 +134,6 @@ public abstract class QueueWorker<E> extends Worker
{
queue.clear();
}
-
- queue = null;
}
}
}

Back to the top