mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-14 12:25:21 +00:00
8086208: java/lang/ProcessHandle/OnExitTest.java: IllegalThreadStateException: process hasn't exited
Reviewed-by: martin, dholmes
This commit is contained in:
parent
1534835fb7
commit
cacb730235
@ -542,7 +542,22 @@ final class ProcessImpl extends Process {
|
||||
@Override
|
||||
public CompletableFuture<Process> onExit() {
|
||||
return ProcessHandleImpl.completion(pid, false)
|
||||
.handleAsync((exitStatus, unusedThrowable) -> this);
|
||||
.handleAsync((exitStatus, unusedThrowable) -> {
|
||||
boolean interrupted = false;
|
||||
while (true) {
|
||||
// Ensure that the concurrent task setting the exit status has completed
|
||||
try {
|
||||
waitFor();
|
||||
break;
|
||||
} catch (InterruptedException ie) {
|
||||
interrupted = true;
|
||||
}
|
||||
}
|
||||
if (interrupted) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
return this;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -26,21 +26,17 @@ import java.lang.InterruptedException;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.stream.Collectors;
|
||||
import jdk.testlibrary.Platform;
|
||||
import org.testng.annotations.Test;
|
||||
import org.testng.Assert;
|
||||
import org.testng.TestNG;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @library /lib/testlibrary
|
||||
* @summary Functions of Process.onExit and ProcessHandle.onExit
|
||||
* @author Roger Riggs
|
||||
*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user