You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2023/12/30 13:03:01 UTC

(commons-exec) branch master updated (d5e41ebb -> aaa3b48e)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-exec.git


    from d5e41ebb Prepare release candidate
     new aea3ecfd [EXEC-78] No need to use System.class.getMethod("getenv",...) any more
     new 4fb9ffb1 Javadoc and better parameter names
     new 2aa5a173 Javdoc
     new 272d56a9 Javdoc
     new 7cf25712 Internal refactoring
     new 57f5e9fd Fix Javadoc obsolete comment
     new 6e234d97 Javadoc
     new 3dda40d3 Proper set up and teardown of system properties in test
     new aaa3b48e Proper set up and teardown of system properties in test

The 9 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 pom.xml                                            |  7 ++
 src/changes/changes.xml                            |  1 +
 .../org/apache/commons/exec/DefaultExecutor.java   | 81 ++++++++++++----------
 .../apache/commons/exec/ExecuteStreamHandler.java  | 24 +++----
 .../org/apache/commons/exec/ProcessDestroyer.java  |  4 +-
 .../commons/exec/ShutdownHookProcessDestroyer.java | 12 ++--
 .../commons/exec/launcher/CommandLauncher.java     | 16 ++---
 .../apache/commons/exec/DefaultExecutorTest.java   |  9 ++-
 .../apache/commons/exec/LogOutputStreamTest.java   | 24 ++-----
 9 files changed, 87 insertions(+), 91 deletions(-)


(commons-exec) 05/09: Internal refactoring

Posted by gg...@apache.org.
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 7cf25712527441a5410d486286949c71704b84c2
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Dec 30 06:45:18 2023 -0500

    Internal refactoring
    
    - Better parameter names
    - Use this in ctors and setters only
---
 .../org/apache/commons/exec/DefaultExecutor.java   | 81 ++++++++++++----------
 1 file changed, 43 insertions(+), 38 deletions(-)

diff --git a/src/main/java/org/apache/commons/exec/DefaultExecutor.java b/src/main/java/org/apache/commons/exec/DefaultExecutor.java
index 42e1ac37..5bfb47b9 100644
--- a/src/main/java/org/apache/commons/exec/DefaultExecutor.java
+++ b/src/main/java/org/apache/commons/exec/DefaultExecutor.java
@@ -164,7 +164,7 @@ public class DefaultExecutor implements Executor {
             watchdog.setProcessNotStarted();
         }
 
-        this.executorThread = createThread(() -> {
+        executorThread = createThread(() -> {
             int exitValue = Executor.INVALID_EXITVALUE;
             try {
                 exitValue = executeInternal(command, environment, workingDirectory, streamHandler);
@@ -181,21 +181,21 @@ public class DefaultExecutor implements Executor {
     /**
      * Execute an internal process. If the executing thread is interrupted while waiting for the child process to return the child process will be killed.
      *
-     * @param command     the command to execute.
-     * @param environment the execution environment.
-     * @param dir         the working directory.
-     * @param streams     process the streams (in, out, err) of the process.
+     * @param command          the command to execute.
+     * @param environment      the execution environment.
+     * @param workingDirectory the working directory.
+     * @param streams          process the streams (in, out, err) of the process.
      * @return the exit code of the process.
      * @throws IOException executing the process failed.
      */
-    private int executeInternal(final CommandLine command, final Map<String, String> environment, final File dir, final ExecuteStreamHandler streams)
-            throws IOException {
+    private int executeInternal(final CommandLine command, final Map<String, String> environment, final File workingDirectory,
+            final ExecuteStreamHandler streams) throws IOException {
 
         final Process process;
         exceptionCaught = null;
 
         try {
-            process = this.launch(command, environment, dir);
+            process = launch(command, environment, workingDirectory);
         } catch (final IOException e) {
             if (watchdog != null) {
                 watchdog.failedToStart(e);
@@ -204,9 +204,7 @@ public class DefaultExecutor implements Executor {
         }
 
         try {
-            streams.setProcessInputStream(process.getOutputStream());
-            streams.setProcessOutputStream(process.getInputStream());
-            streams.setProcessErrorStream(process.getErrorStream());
+            setStreams(streams, process);
         } catch (final IOException e) {
             process.destroy();
             if (watchdog != null) {
@@ -220,8 +218,8 @@ public class DefaultExecutor implements Executor {
         try {
 
             // add the process to the list of those to destroy if the VM exits
-            if (this.getProcessDestroyer() != null) {
-                this.getProcessDestroyer().add(process);
+            if (getProcessDestroyer() != null) {
+                getProcessDestroyer().add(process);
             }
 
             // associate the watchdog with the newly created process
@@ -269,26 +267,33 @@ public class DefaultExecutor implements Executor {
                 }
             }
 
-            if (this.isFailure(exitValue)) {
+            if (isFailure(exitValue)) {
                 throw new ExecuteException("Process exited with an error: " + exitValue, exitValue);
             }
 
             return exitValue;
         } finally {
             // remove the process to the list of those to destroy if the VM exits
-            if (this.getProcessDestroyer() != null) {
-                this.getProcessDestroyer().remove(process);
+            if (getProcessDestroyer() != null) {
+                getProcessDestroyer().remove(process);
             }
         }
     }
 
+    @SuppressWarnings("resource")
+    private void setStreams(final ExecuteStreamHandler streams, final Process process) throws IOException {
+        streams.setProcessInputStream(process.getOutputStream());
+        streams.setProcessOutputStream(process.getInputStream());
+        streams.setProcessErrorStream(process.getErrorStream());
+    }
+
     /**
      * Gets the first IOException being thrown.
      *
      * @return the first IOException being caught.
      */
     private IOException getExceptionCaught() {
-        return this.exceptionCaught;
+        return exceptionCaught;
     }
 
     /**
@@ -305,7 +310,7 @@ public class DefaultExecutor implements Executor {
      */
     @Override
     public ProcessDestroyer getProcessDestroyer() {
-        return this.processDestroyer;
+        return processDestroyer;
     }
 
     /**
@@ -336,13 +341,13 @@ public class DefaultExecutor implements Executor {
     @Override
     public boolean isFailure(final int exitValue) {
 
-        if (this.exitValues == null) {
+        if (exitValues == null) {
             return false;
         }
-        if (this.exitValues.length == 0) {
-            return this.launcher.isFailure(exitValue);
+        if (exitValues.length == 0) {
+            return launcher.isFailure(exitValue);
         }
-        for (final int exitValue2 : this.exitValues) {
+        for (final int exitValue2 : exitValues) {
             if (exitValue2 == exitValue) {
                 return false;
             }
@@ -353,22 +358,22 @@ public class DefaultExecutor implements Executor {
     /**
      * Creates a process that runs a command.
      *
-     * @param command the command to run.
-     * @param env     the environment for the command.
-     * @param dir     the working directory for the command.
+     * @param command          the command to run.
+     * @param env              the environment for the command.
+     * @param workingDirectory the working directory for the command.
      * @return the process started.
      * @throws IOException forwarded from the particular launcher used.
      */
-    protected Process launch(final CommandLine command, final Map<String, String> env, final File dir) throws IOException {
+    protected Process launch(final CommandLine command, final Map<String, String> env, final File workingDirectory) throws IOException {
 
-        if (this.launcher == null) {
+        if (launcher == null) {
             throw new IllegalStateException("CommandLauncher can not be null");
         }
 
-        if (dir != null && !dir.exists()) {
-            throw new IOException(dir + " doesn't exist.");
+        if (workingDirectory != null && !workingDirectory.exists()) {
+            throw new IOException(workingDirectory + " doesn't exist.");
         }
-        return this.launcher.exec(command, env, dir);
+        return launcher.exec(command, env, workingDirectory);
     }
 
     /**
@@ -377,21 +382,21 @@ public class DefaultExecutor implements Executor {
      * @param e the IOException.
      */
     private void setExceptionCaught(final IOException e) {
-        if (this.exceptionCaught == null) {
-            this.exceptionCaught = e;
+        if (exceptionCaught == null) {
+            exceptionCaught = e;
         }
     }
 
     /** @see org.apache.commons.exec.Executor#setExitValue(int) */
     @Override
     public void setExitValue(final int value) {
-        this.setExitValues(new int[] { value });
+        setExitValues(new int[] { value });
     }
 
     /** @see org.apache.commons.exec.Executor#setExitValues(int[]) */
     @Override
     public void setExitValues(final int[] values) {
-        this.exitValues = values == null ? null : (int[]) values.clone();
+        exitValues = values == null ? null : (int[]) values.clone();
     }
 
     /**
@@ -414,16 +419,16 @@ public class DefaultExecutor implements Executor {
      * @see org.apache.commons.exec.Executor#setWatchdog(org.apache.commons.exec.ExecuteWatchdog)
      */
     @Override
-    public void setWatchdog(final ExecuteWatchdog watchDog) {
-        this.watchdog = watchDog;
+    public void setWatchdog(final ExecuteWatchdog watchdog) {
+        this.watchdog = watchdog;
     }
 
     /**
      * @see org.apache.commons.exec.Executor#setWorkingDirectory(java.io.File)
      */
     @Override
-    public void setWorkingDirectory(final File dir) {
-        this.workingDirectory = dir;
+    public void setWorkingDirectory(final File workingDirectory) {
+        this.workingDirectory = workingDirectory;
     }
 
 }


(commons-exec) 09/09: Proper set up and teardown of system properties in test

Posted by gg...@apache.org.
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 aaa3b48e43816cef57347edd43140fe6b96d13d3
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Dec 30 08:02:56 2023 -0500

    Proper set up and teardown of system properties in test
    
    Remove dead comments
---
 pom.xml                                            |  7 +++++++
 .../apache/commons/exec/LogOutputStreamTest.java   | 24 ++++------------------
 2 files changed, 11 insertions(+), 20 deletions(-)

diff --git a/pom.xml b/pom.xml
index ca71df34..46400a1e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -72,6 +72,13 @@
       <artifactId>junit-jupiter-engine</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.junit-pioneer</groupId>
+      <artifactId>junit-pioneer</artifactId>
+      <!-- Version 2.x requires Java 11 -->
+      <version>1.9.1</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>
diff --git a/src/test/java/org/apache/commons/exec/LogOutputStreamTest.java b/src/test/java/org/apache/commons/exec/LogOutputStreamTest.java
index 1e605a75..1f084c88 100644
--- a/src/test/java/org/apache/commons/exec/LogOutputStreamTest.java
+++ b/src/test/java/org/apache/commons/exec/LogOutputStreamTest.java
@@ -29,10 +29,14 @@ import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
+import org.junitpioneer.jupiter.SetSystemProperty;
 
 /**
  * Test the LogOutputStream.
  */
+// turn on debug mode and throw an exception for each encountered problem
+@SetSystemProperty(key = "org.apache.commons.exec.lenient", value = "false")
+@SetSystemProperty(key = "org.apache.commons.exec.debug", value = "true")
 public class LogOutputStreamTest {
 
     private static final class SystemLogOutputStream extends LogOutputStream {
@@ -58,13 +62,6 @@ public class LogOutputStreamTest {
         }
     }
 
-    @BeforeAll
-    public static void classSetUp() {
-        // turn on debug mode and throw an exception for each encountered problem
-        System.setProperty("org.apache.commons.exec.lenient", "false");
-        System.setProperty("org.apache.commons.exec.debug", "true");
-    }
-
     private final Executor exec = new DefaultExecutor();
     private final File testDir = new File("src/test/scripts");
     private OutputStream systemOut;
@@ -73,15 +70,6 @@ public class LogOutputStreamTest {
 
     private final File utf8CharacterScript = TestUtil.resolveScriptForOS(testDir + "/utf8Characters");
 
-    @BeforeEach
-    public void setUp() throws Exception {
-
-    }
-
-    // ======================================================================
-    // Start of regression tests
-    // ======================================================================
-
     @AfterEach
     public void tearDown() throws Exception {
         if (this.systemOut != null) {
@@ -99,10 +87,6 @@ public class LogOutputStreamTest {
         assertFalse(exec.isFailure(exitValue));
     }
 
-    // ======================================================================
-    // Helper classes
-    // ======================================================================
-
     @Test
     @Disabled("The file utf8CharacterScript is missing from the repository and is not in its history")
     public void testStdoutWithUTF8Characters() throws Exception {


(commons-exec) 02/09: Javadoc and better parameter names

Posted by gg...@apache.org.
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 4fb9ffb17aad6efc98b7d76ce9ac9c5d1b1a4ac3
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Dec 30 06:39:54 2023 -0500

    Javadoc and better parameter names
---
 .../apache/commons/exec/ExecuteStreamHandler.java  | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/main/java/org/apache/commons/exec/ExecuteStreamHandler.java b/src/main/java/org/apache/commons/exec/ExecuteStreamHandler.java
index 00334cd2..4de3b267 100644
--- a/src/main/java/org/apache/commons/exec/ExecuteStreamHandler.java
+++ b/src/main/java/org/apache/commons/exec/ExecuteStreamHandler.java
@@ -27,38 +27,38 @@ import java.io.OutputStream;
 public interface ExecuteStreamHandler {
 
     /**
-     * Install a handler for the error stream of the subprocess.
+     * Sets a handler for the error stream of the subprocess.
      *
-     * @param is input stream to read from the error stream from the subprocess.
+     * @param inputStream input stream to read from the error stream from the subprocess.
      * @throws IOException thrown when an I/O exception occurs.
      */
-    void setProcessErrorStream(InputStream is) throws IOException;
+    void setProcessErrorStream(InputStream inputStream) throws IOException;
 
     /**
-     * Install a handler for the input stream of the subprocess.
+     * Sets a handler for the input stream of the subprocess.
      *
-     * @param os output stream to write to the standard input stream of the subprocess.
+     * @param outputStream output stream to write to the standard input stream of the subprocess.
      * @throws IOException thrown when an I/O exception occurs.
      */
-    void setProcessInputStream(OutputStream os) throws IOException;
+    void setProcessInputStream(OutputStream outputStream) throws IOException;
 
     /**
-     * Install a handler for the output stream of the subprocess.
+     * Sets a handler for the output stream of the subprocess.
      *
-     * @param is input stream to read from the error stream from the subprocess.
+     * @param inputStream input stream to read from the error stream from the subprocess.
      * @throws IOException thrown when an I/O exception occurs.
      */
-    void setProcessOutputStream(InputStream is) throws IOException;
+    void setProcessOutputStream(InputStream inputStream) throws IOException;
 
     /**
-     * Start handling of the streams.
+     * Starts handling of the streams.
      *
      * @throws IOException thrown when an I/O exception occurs.
      */
     void start() throws IOException;
 
     /**
-     * Stop handling of the streams - will not be restarted. Will wait for pump threads to complete.
+     * Stops handling of the streams - will not be restarted. Will wait for pump threads to complete.
      *
      * @throws IOException thrown when an I/O exception occurs.
      */


(commons-exec) 03/09: Javdoc

Posted by gg...@apache.org.
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 2aa5a173c96ba7ff22cc01329e42a91d63e1d141
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Dec 30 06:41:09 2023 -0500

    Javdoc
---
 src/main/java/org/apache/commons/exec/ExecuteStreamHandler.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/exec/ExecuteStreamHandler.java b/src/main/java/org/apache/commons/exec/ExecuteStreamHandler.java
index 4de3b267..8302b0b0 100644
--- a/src/main/java/org/apache/commons/exec/ExecuteStreamHandler.java
+++ b/src/main/java/org/apache/commons/exec/ExecuteStreamHandler.java
@@ -22,7 +22,7 @@ import java.io.InputStream;
 import java.io.OutputStream;
 
 /**
- * Used by {@code Execute} to handle input and output stream of subprocesses.
+ * Handles stream of subprocesses for {@link Executor}s.
  */
 public interface ExecuteStreamHandler {
 


(commons-exec) 07/09: Javadoc

Posted by gg...@apache.org.
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 6e234d97e3426e9b64ba5325f75d82638dd3334a
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Dec 30 07:31:18 2023 -0500

    Javadoc
---
 src/main/java/org/apache/commons/exec/ProcessDestroyer.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/commons/exec/ProcessDestroyer.java b/src/main/java/org/apache/commons/exec/ProcessDestroyer.java
index 87ae9f92..0b00022c 100644
--- a/src/main/java/org/apache/commons/exec/ProcessDestroyer.java
+++ b/src/main/java/org/apache/commons/exec/ProcessDestroyer.java
@@ -18,9 +18,9 @@
 package org.apache.commons.exec;
 
 /**
- * Destroys all registered {@link Process} after a certain event, typically when the VM exits
+ * Destroys all registered {@link Process} after a certain event, typically when the VM exits.
  *
- * @see org.apache.commons.exec.ShutdownHookProcessDestroyer
+ * @see ShutdownHookProcessDestroyer
  */
 public interface ProcessDestroyer {
 


(commons-exec) 08/09: Proper set up and teardown of system properties in test

Posted by gg...@apache.org.
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 3dda40d3ff24d872e410eb74da56f9a41c5d68d0
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Dec 30 08:01:43 2023 -0500

    Proper set up and teardown of system properties in test
---
 src/test/java/org/apache/commons/exec/DefaultExecutorTest.java | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java b/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java
index b02553cb..0f12ce6d 100644
--- a/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java
+++ b/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java
@@ -45,9 +45,13 @@ import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
+import org.junitpioneer.jupiter.SetSystemProperty;
 
 /**
  */
+//turn on debug mode and throw an exception for each encountered problem
+@SetSystemProperty(key = "org.apache.commons.exec.lenient", value = "false")
+@SetSystemProperty(key = "org.apache.commons.exec.debug", value = "true")
 public class DefaultExecutorTest {
 
     /** Maximum time to wait (15s) */
@@ -60,14 +64,9 @@ public class DefaultExecutorTest {
 
     @BeforeAll
     public static void classSetUp() {
-
         final int[] statuses = TestUtil.getTestScriptCodesForOS();
         SUCCESS_STATUS = statuses[0];
         ERROR_STATUS = statuses[1];
-
-        // turn on debug mode and throw an exception for each encountered problem
-        System.setProperty("org.apache.commons.exec.lenient", "false");
-        System.setProperty("org.apache.commons.exec.debug", "true");
     }
 
     private final Executor exec = new DefaultExecutor();


(commons-exec) 01/09: [EXEC-78] No need to use System.class.getMethod("getenv",...) any more

Posted by gg...@apache.org.
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 aea3ecfdaea692c892e3e0b0f3d7f51661408e63
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Dec 29 19:33:32 2023 -0500

    [EXEC-78] No need to use System.class.getMethod("getenv",...) any more
---
 src/changes/changes.xml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index e8878f1e..6542041d 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -44,6 +44,7 @@
             <action dev="ggregory" type="fix" due-to="Gary Gregory">ExecuteException propagates its cause to its IOException superclass.</action>
             <action dev="ggregory" type="fix" due-to="Gary Gregory">Propagate exception in DebugUtils.handleException(String, Exception).</action>
             <action dev="ggregory" type="fix" due-to="Gary Gregory">Deprecate StringUtils.toString(String[], String) in favor of String.join(CharSequence, CharSequence...).</action>
+            <action issue="EXEC-78" dev="ggregory" type="fix">No need to use System.class.getMethod("getenv",...) any more.</action>
             <!-- REMOVE -->
             <action dev="ggregory" type="remove" due-to="Gary Gregory">Deprecate DefaultExecuteResultHandler.waitFor(long).</action>
             <action dev="ggregory" type="remove" due-to="Gary Gregory">Deprecate ExecuteWatchdog.ExecuteWatchdog(long).</action>


(commons-exec) 06/09: Fix Javadoc obsolete comment

Posted by gg...@apache.org.
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 57f5e9fd726fc8350de2e35c8d1d6f411676dc6d
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Dec 30 07:31:07 2023 -0500

    Fix Javadoc obsolete comment
    
    - Better internal class name
    - Don't initialize instance variable to its default value
---
 .../apache/commons/exec/ShutdownHookProcessDestroyer.java    | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/commons/exec/ShutdownHookProcessDestroyer.java b/src/main/java/org/apache/commons/exec/ShutdownHookProcessDestroyer.java
index 3795ac47..8a8cafbb 100644
--- a/src/main/java/org/apache/commons/exec/ShutdownHookProcessDestroyer.java
+++ b/src/main/java/org/apache/commons/exec/ShutdownHookProcessDestroyer.java
@@ -24,11 +24,11 @@ import java.util.Vector;
  */
 public class ShutdownHookProcessDestroyer implements ProcessDestroyer, Runnable {
 
-    private final class ProcessDestroyerImpl extends Thread {
+    private final class ProcessDestroyerThread extends Thread {
 
         private boolean shouldDestroy = true;
 
-        public ProcessDestroyerImpl() {
+        public ProcessDestroyerThread() {
             super("ProcessDestroyer Shutdown Hook");
         }
 
@@ -48,7 +48,7 @@ public class ShutdownHookProcessDestroyer implements ProcessDestroyer, Runnable
     private final Vector<Process> processes = new Vector<>();
 
     /** The thread registered at the JVM to execute the shutdown handler. */
-    private ProcessDestroyerImpl destroyProcessThread;
+    private ProcessDestroyerThread destroyProcessThread;
 
     /** Whether or not this ProcessDestroyer has been registered as a shutdown hook. */
     private boolean added;
@@ -56,7 +56,7 @@ public class ShutdownHookProcessDestroyer implements ProcessDestroyer, Runnable
     /**
      * Whether or not this ProcessDestroyer is currently running as shutdown hook.
      */
-    private volatile boolean running = false;
+    private volatile boolean running;
 
     /**
      * Constructs a {@code ProcessDestroyer} and obtains {@code Runtime.addShutdownHook()} and {@code Runtime.removeShutdownHook()} through reflection. The
@@ -86,11 +86,11 @@ public class ShutdownHookProcessDestroyer implements ProcessDestroyer, Runnable
     }
 
     /**
-     * Registers this {@code ProcessDestroyer} as a shutdown hook, uses reflection to ensure pre-JDK 1.3 compatibility.
+     * Registers this {@code ProcessDestroyer} as a shutdown hook.
      */
     private void addShutdownHook() {
         if (!running) {
-            destroyProcessThread = new ProcessDestroyerImpl();
+            destroyProcessThread = new ProcessDestroyerThread();
             Runtime.getRuntime().addShutdownHook(destroyProcessThread);
             added = true;
         }


(commons-exec) 04/09: Javdoc

Posted by gg...@apache.org.
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 272d56a90df3bcac1088d546ae996d8cb27b2503
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Dec 30 06:43:31 2023 -0500

    Javdoc
---
 .../apache/commons/exec/launcher/CommandLauncher.java    | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/main/java/org/apache/commons/exec/launcher/CommandLauncher.java b/src/main/java/org/apache/commons/exec/launcher/CommandLauncher.java
index 98c4258f..69869390 100644
--- a/src/main/java/org/apache/commons/exec/launcher/CommandLauncher.java
+++ b/src/main/java/org/apache/commons/exec/launcher/CommandLauncher.java
@@ -24,30 +24,30 @@ import java.util.Map;
 import org.apache.commons.exec.CommandLine;
 
 /**
- * Abstracts the various platform-dependent implementations.
+ * Abstracts platform-dependent implementations.
  */
 public interface CommandLauncher {
 
     /**
      * Executes the given command in a new process.
      *
-     * @param cmd The command to execute.
-     * @param env The environment for the new process. If null, the environment of the current process is used.
+     * @param commandLine The command to execute.
+     * @param env         The environment for the new process. If null, the environment of the current process is used.
      * @return the newly created process.
      * @throws IOException if attempting to run a command in a specific directory.
      */
-    Process exec(final CommandLine cmd, final Map<String, String> env) throws IOException;
+    Process exec(final CommandLine commandLine, final Map<String, String> env) throws IOException;
 
     /**
      * Executes the given command in a new process, in the given working directory.
      *
-     * @param cmd        The command to execute.
-     * @param env        The environment for the new process. If null, the environment of the current process is used.
-     * @param workingDir The directory to start the command in. If null, the current directory is used.
+     * @param commandLine      The command to execute.
+     * @param env              The environment for the new process. If null, the environment of the current process is used.
+     * @param workingDirectory The directory to start the command in. If null, the current directory is used.
      * @return the newly created process.
      * @throws IOException if trying to change directory.
      */
-    Process exec(final CommandLine cmd, final Map<String, String> env, final File workingDir) throws IOException;
+    Process exec(final CommandLine commandLine, final Map<String, String> env, final File workingDirectory) throws IOException;
 
     /**
      * Tests whether {@code exitValue} signals a failure on the current system (OS specific).