From 26ecac7b30b38b376f9c77d8b4deb7e4202585b4 Mon Sep 17 00:00:00 2001 From: Moses Nakamura Date: Sun, 14 May 2023 20:23:25 -0400 Subject: [PATCH] checkstyle-compat --- ...CompletableFutureExecuteResultHandler.java | 4 ++-- .../ch/vorburger/exec/ManagedProcess.java | 20 +++++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/main/java/ch/vorburger/exec/CompletableFutureExecuteResultHandler.java b/src/main/java/ch/vorburger/exec/CompletableFutureExecuteResultHandler.java index edf16b5..c32df1d 100644 --- a/src/main/java/ch/vorburger/exec/CompletableFutureExecuteResultHandler.java +++ b/src/main/java/ch/vorburger/exec/CompletableFutureExecuteResultHandler.java @@ -38,7 +38,7 @@ public CompletableFutureExecuteResultHandler(CompletableFuture asyncRes */ @Override public void onProcessComplete(int exitValue) { - asyncResult.complete(exitValue); + asyncResult.complete(exitValue); } /** @@ -48,6 +48,6 @@ public void onProcessComplete(int exitValue) { */ @Override public void onProcessFailed(ExecuteException e) { - asyncResult.completeExceptionally(e); + asyncResult.completeExceptionally(e); } } diff --git a/src/main/java/ch/vorburger/exec/ManagedProcess.java b/src/main/java/ch/vorburger/exec/ManagedProcess.java index 788107f..b654f39 100644 --- a/src/main/java/ch/vorburger/exec/ManagedProcess.java +++ b/src/main/java/ch/vorburger/exec/ManagedProcess.java @@ -132,8 +132,7 @@ public class ManagedProcess implements ManagedProcessState { this.consoleBufferMaxLines = consoleBufferMaxLines; this.outputStreamLogDispatcher = outputStreamLogDispatcher; this.asyncResult = new CompletableFuture<>(); - var unused = this.asyncResult.handle((result, e) -> - { + CompletableFuture unused = this.asyncResult.handle((result, e) -> { if (e == null) { logger.info(this.getProcLongName() + " just exited, with value " + result); listener.onProcessComplete(result); @@ -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) { @@ -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);