Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2013-10-14 12:41:20 +0000
committerEike Stepper2013-10-14 12:41:20 +0000
commit632884c15c9e7ae97940cb3949585954d981ccf8 (patch)
tree4a259cc6587ca62c4193ab9d178c03ab76f6ae74 /plugins/org.eclipse.emf.cdo.server
parent2ec08800feb6d88615bcd48c3db279542de28cd2 (diff)
downloadcdo-632884c15c9e7ae97940cb3949585954d981ccf8.tar.gz
cdo-632884c15c9e7ae97940cb3949585954d981ccf8.tar.xz
cdo-632884c15c9e7ae97940cb3949585954d981ccf8.zip
[419356] Handle exception during asynchronous queries in result order
https://bugs.eclipse.org/bugs/show_bug.cgi?id=419356
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.server')
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/QueryManager.java28
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/mem/MEMStoreAccessor.java58
2 files changed, 70 insertions, 16 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/QueryManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/QueryManager.java
index d2671bb16b..765f9703e7 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/QueryManager.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/QueryManager.java
@@ -14,6 +14,7 @@ package org.eclipse.emf.cdo.internal.server;
import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
import org.eclipse.emf.cdo.common.util.CDOQueryInfo;
+import org.eclipse.emf.cdo.common.util.CDOQueryQueue;
import org.eclipse.emf.cdo.internal.server.bundle.OM;
import org.eclipse.emf.cdo.server.IQueryContext;
import org.eclipse.emf.cdo.server.IQueryHandler;
@@ -276,30 +277,47 @@ public class QueryManager extends Lifecycle implements InternalQueryManager
throw new IllegalStateException("Maximum number of results exceeded"); //$NON-NLS-1$
}
- queryResult.getQueue().add(object);
+ CDOQueryQueue<Object> queue = queryResult.getQueue();
+ queue.add(object);
+
return !cancelled && --resultCount > 0;
}
public void run()
{
+ CDOQueryQueue<Object> queue = queryResult.getQueue();
+
InternalSession session = queryResult.getView().getSession();
StoreThreadLocal.setSession(session);
try
{
started = true;
+
CDOQueryInfo info = queryResult.getQueryInfo();
resultCount = info.getMaxResults() < 0 ? Integer.MAX_VALUE : info.getMaxResults();
IQueryHandler handler = repository.getQueryHandler(info);
- handler.executeQuery(info, this);
+
+ try
+ {
+ handler.executeQuery(info, this);
+ }
+ catch (Throwable executionException)
+ {
+ // int xxx;
+ // ConcurrencyUtil.sleep(2000);
+
+ addResult(executionException);
+ return;
+ }
}
- catch (Throwable exception)
+ catch (Throwable initializationException)
{
- queryResult.getQueue().setException(exception);
+ queue.setException(initializationException);
}
finally
{
- queryResult.getQueue().close();
+ queue.close();
unregister(this);
StoreThreadLocal.release();
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/mem/MEMStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/mem/MEMStoreAccessor.java
index 60f673f20a..5e64a55a3a 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/mem/MEMStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/mem/MEMStoreAccessor.java
@@ -71,6 +71,15 @@ public class MEMStoreAccessor extends LongIDStoreAccessor implements Raw, Durabl
List<Object> filters = new ArrayList<Object>();
Object context = info.getParameters().get("context"); //$NON-NLS-1$
Long sleep = (Long)info.getParameters().get("sleep"); //$NON-NLS-1$
+ Integer integers = (Integer)info.getParameters().get("integers"); //$NON-NLS-1$
+ Integer error = (Integer)info.getParameters().get("error"); //$NON-NLS-1$
+
+ if (integers != null)
+ {
+ executeQuery(integers, error, queryContext);
+ return;
+ }
+
if (context != null)
{
if (context instanceof EClass)
@@ -94,6 +103,7 @@ public class MEMStoreAccessor extends LongIDStoreAccessor implements Raw, Durabl
}
}
+ int i = 0;
for (InternalCDORevision revision : getStore().getCurrentRevisions())
{
if (sleep != null)
@@ -108,19 +118,10 @@ public class MEMStoreAccessor extends LongIDStoreAccessor implements Raw, Durabl
}
}
- boolean valid = true;
-
- for (Object filter : filters)
+ if (isValid(revision, filters))
{
- if (!filter.equals(revision))
- {
- valid = false;
- break;
- }
- }
+ throwExceptionAt(error, ++i);
- if (valid)
- {
if (!queryContext.addResult(revision))
{
// No more results allowed
@@ -129,6 +130,41 @@ public class MEMStoreAccessor extends LongIDStoreAccessor implements Raw, Durabl
}
}
}
+
+ private void throwExceptionAt(Integer error, int i)
+ {
+ if (error != null && i == error)
+ {
+ throw new RuntimeException("Simulated problem in query execution at result " + i);
+ }
+ }
+
+ private void executeQuery(int integers, Integer error, IQueryContext queryContext)
+ {
+ for (int i = 1; i <= integers; ++i)
+ {
+ throwExceptionAt(error, i);
+
+ if (!queryContext.addResult(i))
+ {
+ // No more results allowed
+ break;
+ }
+ }
+ }
+
+ private boolean isValid(InternalCDORevision revision, List<Object> filters)
+ {
+ for (Object filter : filters)
+ {
+ if (!filter.equals(revision))
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
};
private List<InternalCDORevision> newRevisions = new ArrayList<InternalCDORevision>();

Back to the top