Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2012-12-20 01:52:27 +0000
committerRoberto E. Escobar2012-12-20 01:52:27 +0000
commit4a0e0fcc87b995f7456dec6ff028aef1bc7126ae (patch)
tree9fb67ec50f595cda82b8d195abadb227a0d0dd99 /plugins/org.eclipse.osee.framework.manager.servlet
parent38388a1b7339bdba67cf7e5acb9ae24708a2e9e3 (diff)
downloadorg.eclipse.osee-4a0e0fcc87b995f7456dec6ff028aef1bc7126ae.tar.gz
org.eclipse.osee-4a0e0fcc87b995f7456dec6ff028aef1bc7126ae.tar.xz
org.eclipse.osee-4a0e0fcc87b995f7456dec6ff028aef1bc7126ae.zip
bug[ats_4V9M7]: Waiting on search indexer not thread safe
This causes clients to wait indefinitely on indexer. Changed counters to be atomic to prevent concurrency issues. Change-Id: Id14d6dc0fdc818b5371816d8c0328fc770c5d6eb
Diffstat (limited to 'plugins/org.eclipse.osee.framework.manager.servlet')
-rw-r--r--plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/SearchEngineTaggerServlet.java45
1 files changed, 24 insertions, 21 deletions
diff --git a/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/SearchEngineTaggerServlet.java b/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/SearchEngineTaggerServlet.java
index 35692aaa3e6..bce38893471 100644
--- a/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/SearchEngineTaggerServlet.java
+++ b/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/SearchEngineTaggerServlet.java
@@ -13,6 +13,7 @@ package org.eclipse.osee.framework.manager.servlet;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.concurrent.Callable;
+import java.util.concurrent.atomic.AtomicInteger;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.osee.framework.core.server.ISessionManager;
@@ -53,28 +54,8 @@ public class SearchEngineTaggerServlet extends SecureOseeHttpServlet {
boolean waitForTags = Boolean.parseBoolean(request.getParameter("wait"));
QueryIndexer indexer = getQueryIndexer(request);
if (waitForTags) {
- IndexerCollector collector = new IndexerCollectorAdapter() {
-
- int totalToProcess = 0;
- int currentCount = 0;
-
- @Override
- public void onIndexTaskComplete(int indexerId, long waitTime, long processingTime) {
- currentCount++;
- if (currentCount >= totalToProcess) {
- synchronized (this) {
- notify();
- }
- }
- }
-
- @Override
- public void onIndexTaskTotalToProcess(int totalQueries) {
- totalToProcess = totalQueries;
- }
-
- };
+ IndexerCollector collector = new WaitForIndexerCollector();
Callable<?> callable = indexer.indexXmlStream(collector, request.getInputStream());
callable.call();
synchronized (collector) {
@@ -118,4 +99,26 @@ public class SearchEngineTaggerServlet extends SecureOseeHttpServlet {
response.getWriter().close();
}
}
+
+ private static class WaitForIndexerCollector extends IndexerCollectorAdapter {
+
+ private final AtomicInteger totalToProcess = new AtomicInteger();
+ private final AtomicInteger currentCount = new AtomicInteger();
+
+ @Override
+ public void onIndexTaskComplete(int indexerId, long waitTime, long processingTime) {
+ int count = currentCount.incrementAndGet();
+ if (count >= totalToProcess.get()) {
+ synchronized (this) {
+ notify();
+ }
+ }
+ }
+
+ @Override
+ public void onIndexTaskTotalToProcess(int totalQueries) {
+ totalToProcess.set(totalQueries);
+ }
+
+ };
}

Back to the top