Skip to content

Commit

Permalink
checkstyle-compat
Browse files Browse the repository at this point in the history
  • Loading branch information
mosesn committed May 15, 2023
1 parent 822cfc6 commit 26ecac7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public CompletableFutureExecuteResultHandler(CompletableFuture<Integer> asyncRes
*/
@Override
public void onProcessComplete(int exitValue) {
asyncResult.complete(exitValue);
asyncResult.complete(exitValue);
}

/**
Expand All @@ -48,6 +48,6 @@ public void onProcessComplete(int exitValue) {
*/
@Override
public void onProcessFailed(ExecuteException e) {
asyncResult.completeExceptionally(e);
asyncResult.completeExceptionally(e);
}
}
20 changes: 9 additions & 11 deletions src/main/java/ch/vorburger/exec/ManagedProcess.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@ public class ManagedProcess implements ManagedProcessState {
this.consoleBufferMaxLines = consoleBufferMaxLines;
this.outputStreamLogDispatcher = outputStreamLogDispatcher;
this.asyncResult = new CompletableFuture<>();
var unused = this.asyncResult.<Void>handle((result, e) ->
{
CompletableFuture<Void> unused = this.asyncResult.<Void>handle((result, e) -> {
if (e == null) {
logger.info(this.getProcLongName() + " just exited, with value " + result);
listener.onProcessComplete(result);
Expand All @@ -142,14 +141,13 @@ public class ManagedProcess implements ManagedProcessState {
if (e instanceof ExecuteException) {
ExecuteException ee = (ExecuteException) e;
listener.onProcessFailed(ee.getExitValue(), ee);
} // TODO handle non-ExecuteException cases gracefully
} // TODO handle non-ExecuteException cases gracefully
}
if (e != null && !(e instanceof CancellationException)) {
if (e != null && !(e instanceof CancellationException)) {
this.notifyProcessHalted();
}
return null;
}
);
});
this.stdoutOS = new MultiOutputStream();
this.stderrOS = new MultiOutputStream();
for (OutputStream stdOut : stdOuts) {
Expand Down Expand Up @@ -344,11 +342,11 @@ protected ManagedProcessException handleException(Exception e)
protected void checkResult() throws ManagedProcessException {
if (asyncResult.isCompletedExceptionally()) {
// We already terminated (or never started)
try {
asyncResult.get(); // just called to throw the exception
} catch (InterruptedException e) {
throw handleInterruptedException(e);
} catch (Exception e) {
try {
asyncResult.get(); // just called to throw the exception
} catch (InterruptedException e) {
throw handleInterruptedException(e);
} catch (Exception e) {
logger.error(getProcLongName() + " failed", e);
throw new ManagedProcessException(getProcLongName() + " failed with Exception: " + getLastConsoleLines(),
e);
Expand Down

0 comments on commit 26ecac7

Please sign in to comment.