Future.cancel is asynchronous, so it can return before the process is actually killed

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@23551 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
kohsuke committed 2009-11-06 23:20:06 +00:00
1 parent 461c315daa
commit 8fcda35317
1 file changed
+8 -2
+8 -2
View File
@@ -31,16 +31,16 @@ import hudson.util.ProcessTree;
import java.io.File;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.Callable;
import junit.framework.TestCase;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.FileUtils;
public class LauncherTest extends TestCase {
public LauncherTest(String n) {
super(n);
}
@@ -83,6 +83,7 @@ public class LauncherTest extends TestCase {
assertTrue(p.join()!=0);
long end = System.currentTimeMillis();
assertTrue("join finished promptly", (end - start < 5000));
french.call(NOOP); // this only returns after the other side of the channel has finished executing cancellation
assertNull("process should be gone",ProcessTree.get().get(Integer.parseInt(FileUtils.readFileToString(tmp).trim())));
// Manual version of test: set up instance w/ one slave. Now in script console
@@ -94,4 +95,9 @@ public class LauncherTest extends TestCase {
// hangs and on slave machine pgrep sleep => one process; after manual kill, script returns.
}
private static final hudson.remoting.Callable<Object,RuntimeException> NOOP = new hudson.remoting.Callable() {
public Object call() throws Exception {
return null;
}
};
}