Skip to content

Commit

Permalink
Merge pull request #67 from jamezp/issue64
Browse files Browse the repository at this point in the history
[64] Ensure the future always gets completed for the kill() method.
  • Loading branch information
jamezp authored Aug 7, 2024
2 parents f6a9eff + 4e14041 commit 6c9a636
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,20 @@ public String launchType() {

@Override
public CompletableFuture<ServerManager> kill() {
final CompletableFuture<ServerManager> cf = new CompletableFuture<>();
if (process != null && process.isAlive()) {
internalClose(false, false);
if (process.destroyForcibly()) {
cf.thenCombine(process.onExit(), (serverManager, processHandle) -> serverManager);
if (process != null) {
if (process.isAlive()) {
return CompletableFuture.supplyAsync(() -> {
internalClose(false, false);
return process.destroyForcibly();
}).thenCompose((successfulRequest) -> {
if (successfulRequest) {
return process.onExit().thenApply((processHandle) -> this);
}
return CompletableFuture.completedFuture(this);
});
}
} else {
cf.complete(this);
}
return cf;
return CompletableFuture.completedFuture(this);
}

@Override
Expand Down

0 comments on commit 6c9a636

Please sign in to comment.