This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-exec.git
commit 62488886e828a90f09c10637451eeed176cc32e9 Author: Gary D. Gregory <garydgreg...@gmail.com> AuthorDate: Sun Aug 17 09:31:34 2025 -0400 Internal refactoring in DefaultExecutor and DaemonExecutor --- src/main/java/org/apache/commons/exec/DaemonExecutor.java | 2 +- src/main/java/org/apache/commons/exec/DefaultExecutor.java | 12 ++++++------ src/main/java/org/apache/commons/exec/ExecuteWatchdog.java | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/apache/commons/exec/DaemonExecutor.java b/src/main/java/org/apache/commons/exec/DaemonExecutor.java index 776c49fc..93dcfd01 100644 --- a/src/main/java/org/apache/commons/exec/DaemonExecutor.java +++ b/src/main/java/org/apache/commons/exec/DaemonExecutor.java @@ -73,7 +73,7 @@ public class DaemonExecutor extends DefaultExecutor { } private DaemonExecutor(final Builder builder) { - super(builder.getThreadFactory(), builder.getExecuteStreamHandler(), builder.getWorkingDirectoryPath()); + super(builder); } /** diff --git a/src/main/java/org/apache/commons/exec/DefaultExecutor.java b/src/main/java/org/apache/commons/exec/DefaultExecutor.java index 6860bcd3..a94d7569 100644 --- a/src/main/java/org/apache/commons/exec/DefaultExecutor.java +++ b/src/main/java/org/apache/commons/exec/DefaultExecutor.java @@ -107,7 +107,7 @@ public class DefaultExecutor implements Executor { */ @Override public DefaultExecutor get() { - return new DefaultExecutor(threadFactory, executeStreamHandler, workingDirectory); + return new DefaultExecutor(this); } ExecuteStreamHandler getExecuteStreamHandler() { @@ -218,13 +218,13 @@ public class DefaultExecutor implements Executor { */ @Deprecated public DefaultExecutor() { - this(Executors.defaultThreadFactory(), new PumpStreamHandler(), Paths.get(".")); + this(builder().setExecuteStreamHandler(new PumpStreamHandler()).setWorkingDirectory(Paths.get("."))); } - DefaultExecutor(final ThreadFactory threadFactory, final ExecuteStreamHandler executeStreamHandler, final Path workingDirectory) { - this.threadFactory = threadFactory != null ? threadFactory : Executors.defaultThreadFactory(); - this.executeStreamHandler = executeStreamHandler != null ? executeStreamHandler : new PumpStreamHandler(); - this.workingDirectory = workingDirectory != null ? workingDirectory : Paths.get("."); + DefaultExecutor(final Builder<?> builder) { + this.threadFactory = builder.threadFactory != null ? builder.threadFactory : Executors.defaultThreadFactory(); + this.executeStreamHandler = builder.executeStreamHandler != null ? builder.executeStreamHandler : new PumpStreamHandler(); + this.workingDirectory = builder.workingDirectory != null ? builder.workingDirectory : Paths.get("."); this.launcher = CommandLauncherFactory.createVMLauncher(); this.exitValues = new int[0]; } diff --git a/src/main/java/org/apache/commons/exec/ExecuteWatchdog.java b/src/main/java/org/apache/commons/exec/ExecuteWatchdog.java index b872d8d9..7853b440 100644 --- a/src/main/java/org/apache/commons/exec/ExecuteWatchdog.java +++ b/src/main/java/org/apache/commons/exec/ExecuteWatchdog.java @@ -173,7 +173,7 @@ public class ExecuteWatchdog implements TimeoutObserver { this.processStarted = false; this.threadFactory = builder.threadFactory != null ? builder.threadFactory : Executors.defaultThreadFactory(); if (this.hasWatchdog) { - this.watchdog = Watchdog.builder().setThreadFactory(this.threadFactory).setTimeout(builder.timeout).get(); + this.watchdog = Watchdog.builder().setThreadFactory(threadFactory).setTimeout(builder.timeout).get(); this.watchdog.addTimeoutObserver(this); } else { this.watchdog = null;