msfroh commented on a change in pull request #1585:
URL: https://github.com/apache/lucene-solr/pull/1585#discussion_r441148085



##########
File path: lucene/core/src/java/org/apache/lucene/index/MergePolicy.java
##########
@@ -399,6 +427,23 @@ public String segString(Directory dir) {
       }
       return b.toString();
     }
+
+    /**
+     * Waits if necessary for at most the given time for all merges.
+     */
+    boolean await(long timeout, TimeUnit unit) {
+      try {
+        CompletableFuture<Void> future = 
CompletableFuture.allOf(merges.stream()
+            .map(m -> m.completable).collect(Collectors.toList()).toArray(new 
CompletableFuture<?>[0]));
+        future.get(timeout, unit);
+        return true;
+      } catch (InterruptedException e) {
+        Thread.interrupted();

Review comment:
       In my change, I remember I originally tried handling the 
`InterruptedException` while waiting for the `CountDownLatch` in a similar way, 
but it caused an intermittent test failure (in `TestIndexWriterWithThreads`, 
maybe?) You might run into the same test failure once you start calling this 
`await` method from within `IndexWriter`.
   
   I was able to get the test passing by rethrowing it wrapped in a 
`ThreadInterruptedException`. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to