lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uschind...@apache.org
Subject svn commit: r1684008 - /lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/codecs/TestCodecLoadingDeadlock.java
Date Sun, 07 Jun 2015 09:33:34 GMT
Author: uschindler
Date: Sun Jun  7 09:33:33 2015
New Revision: 1684008

URL: http://svn.apache.org/r1684008
Log:
LUCENE-6482: Fix Java 7, which has very limited Process API (I did not notice before, as I
had Java 8 as default runtime)

Modified:
    lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/codecs/TestCodecLoadingDeadlock.java

Modified: lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/codecs/TestCodecLoadingDeadlock.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/codecs/TestCodecLoadingDeadlock.java?rev=1684008&r1=1684007&r2=1684008&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/codecs/TestCodecLoadingDeadlock.java
(original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/codecs/TestCodecLoadingDeadlock.java
Sun Jun  7 09:33:33 2015
@@ -25,6 +25,8 @@ import java.util.Set;
 import java.util.concurrent.CyclicBarrier;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.lucene.util.LuceneTestCase;
@@ -67,11 +69,20 @@ public class TestCodecLoadingDeadlock ex
       pfName,
       dvfName
     ).inheritIO().start();
-    if (p.waitFor(30, TimeUnit.SECONDS)) {
-      assertEquals("Process died abnormally", 0, p.waitFor());
-    } else {
-      p.destroyForcibly().waitFor();
+    final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(new
NamedThreadFactory("processKiller"));
+    final ScheduledFuture<?> f = scheduler.schedule(new Runnable() {
+      @Override
+      public void run() {
+        p.destroy();
+      }
+    }, 30, TimeUnit.SECONDS);
+    final int exitCode = p.waitFor();
+    scheduler.shutdownNow();
+    while (!scheduler.awaitTermination(1, TimeUnit.MINUTES));
+    if (f.isDone()) {
       fail("Process did not exit after 30 secs -> classloader deadlock?");
+    } else {
+      assertEquals("Process died abnormally", 0, exitCode);
     }
   }
   



Mime
View raw message