Make workspace indexer synchronous
authorMathieu Baudier <mbaudier@argeo.org>
Mon, 27 Jan 2020 12:21:34 +0000 (13:21 +0100)
committerMathieu Baudier <mbaudier@argeo.org>
Mon, 27 Jan 2020 12:21:34 +0000 (13:21 +0100)
org.argeo.cms/src/org/argeo/cms/internal/kernel/CmsWorkspaceIndexer.java

index 14375b99ee63e8570eee5e6cf27375be220970e6..1f534af0d92dab62d433b3352ccba8219ea65872 100644 (file)
@@ -1,6 +1,10 @@
 package org.argeo.cms.internal.kernel;
 
 import java.util.GregorianCalendar;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
 
 import javax.jcr.Node;
 import javax.jcr.Property;
@@ -158,7 +162,13 @@ class CmsWorkspaceIndexer implements EventListener {
                                processEvents(events);
                        }
                };
-               Activator.getInternalExecutorService().execute(toRun);
+               Future<?> future = Activator.getInternalExecutorService().submit(toRun);
+               try {
+                       // make the call synchronous
+                       future.get(60, TimeUnit.SECONDS);
+               } catch (TimeoutException | ExecutionException | InterruptedException e) {
+                       // silent
+               }
        }
 
        static String toEtag(Value v) {