Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sketch of a more invasive CompletableFuture patch #126

Merged
merged 8 commits into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 0 additions & 121 deletions src/main/java/ch/vorburger/exec/AtomicExecuteResultHandler.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,35 @@
*/
package ch.vorburger.exec;

import java.util.concurrent.CompletableFuture;
import org.apache.commons.exec.ExecuteException;
import org.apache.commons.exec.ExecuteResultHandler;

/**
* Extends {@link AtomicExecuteResultHandler} with a listener.
*/
class ProcessResultHandler extends AtomicExecuteResultHandler {
private final ManagedProcessListener listener;
class CompletableFutureExecuteResultHandler implements ExecuteResultHandler {

private final CompletableFuture<Integer> asyncResult;

ProcessResultHandler(ManagedProcessListener listener) {
if (listener == null) {
//set internal listener
this.listener = new ManagedProcessListenerInternal();
} else {
this.listener = listener;
}
public CompletableFutureExecuteResultHandler(CompletableFuture<Integer> asyncResult) {
this.asyncResult = asyncResult;
}

/**
* The asynchronous execution completed.
*
* @param exitValue the exit value of the sub-process
*/
@Override
public void onProcessComplete(int exitValue) {
super.onProcessComplete(exitValue);
listener.onProcessComplete(exitValue);
asyncResult.complete(exitValue);
}

/**
* The asynchronous execution failed.
*
* @param e the {@code ExecuteException} containing the root cause
*/
@Override
public void onProcessFailed(ExecuteException processFailedException) {
super.onProcessFailed(processFailedException);
listener.onProcessFailed(processFailedException.getExitValue(), processFailedException);
public void onProcessFailed(ExecuteException e) {
asyncResult.completeExceptionally(e);
}
}
68 changes: 0 additions & 68 deletions src/main/java/ch/vorburger/exec/CompositeExecuteResultHandler.java

This file was deleted.

57 changes: 0 additions & 57 deletions src/main/java/ch/vorburger/exec/LoggingExecuteResultHandler.java

This file was deleted.

Loading