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


The following commit(s) were added to refs/heads/master by this push:
     new c01ee9a  Use the scale in the var name.
c01ee9a is described below

commit c01ee9a87463682eab74186bed3bc428299f4567
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Tue Feb 2 12:19:03 2021 -0500

    Use the scale in the var name.
---
 .../commons/exec/DefaultExecuteResultHandler.java  |  8 ++++----
 .../org/apache/commons/exec/PumpStreamHandler.java | 18 +++++++++---------
 .../java/org/apache/commons/exec/Watchdog.java     | 22 +++++++++++-----------
 3 files changed, 24 insertions(+), 24 deletions(-)

diff --git 
a/src/main/java/org/apache/commons/exec/DefaultExecuteResultHandler.java 
b/src/main/java/org/apache/commons/exec/DefaultExecuteResultHandler.java
index 9df5043..2a1c646 100644
--- a/src/main/java/org/apache/commons/exec/DefaultExecuteResultHandler.java
+++ b/src/main/java/org/apache/commons/exec/DefaultExecuteResultHandler.java
@@ -130,17 +130,17 @@ public class DefaultExecuteResultHandler implements 
ExecuteResultHandler {
      * not yet terminated, the calling thread will be blocked until the
      * process exits.
      *
-     * @param timeout the maximum time to wait in milliseconds
+     * @param timeoutMillis the maximum time to wait in milliseconds
      * @throws  InterruptedException if the current thread is
      *             {@linkplain Thread#interrupt() interrupted} by another
      *             thread while it is waiting, then the wait is ended and
      *             an {@link InterruptedException} is thrown.
      */
-    public void waitFor(final long timeout) throws InterruptedException {
+    public void waitFor(final long timeoutMillis) throws InterruptedException {
 
-        final long until = System.currentTimeMillis() + timeout;
+        final long untilMillis = System.currentTimeMillis() + timeoutMillis;
 
-        while (!hasResult() && System.currentTimeMillis() < until) {
+        while (!hasResult() && System.currentTimeMillis() < untilMillis) {
             Thread.sleep(SLEEP_TIME_MS);
         }
     }
diff --git a/src/main/java/org/apache/commons/exec/PumpStreamHandler.java 
b/src/main/java/org/apache/commons/exec/PumpStreamHandler.java
index efe5f43..1c13321 100644
--- a/src/main/java/org/apache/commons/exec/PumpStreamHandler.java
+++ b/src/main/java/org/apache/commons/exec/PumpStreamHandler.java
@@ -33,7 +33,7 @@ import java.io.PipedOutputStream;
  */
 public class PumpStreamHandler implements ExecuteStreamHandler {
 
-    private static final long STOP_TIMEOUT_ADDITION = 2000L;
+    private static final long STOP_TIMEOUT_ADDITION_MILLIS = 2000L;
 
     private Thread outputThread;
 
@@ -282,20 +282,20 @@ public class PumpStreamHandler implements 
ExecuteStreamHandler {
      * is created to be thrown to the caller.
      *
      * @param thread  the thread to be stopped
-     * @param timeout the time in ms to wait to join
+     * @param timeoutMillis the time in ms to wait to join
      */
-    protected void stopThread(final Thread thread, final long timeout) {
+    protected void stopThread(final Thread thread, final long timeoutMillis) {
 
         if (thread != null) {
             try {
-                if (timeout == 0) {
+                if (timeoutMillis == 0) {
                     thread.join();
                 } else {
-                    final long timeToWait = timeout + STOP_TIMEOUT_ADDITION;
-                    final long startTime = System.currentTimeMillis();
-                    thread.join(timeToWait);
-                    if (System.currentTimeMillis() > startTime + timeToWait) {
-                        final String msg = "The stop timeout of " + timeout + 
" ms was exceeded";
+                    final long timeToWaitMillis = timeoutMillis + 
STOP_TIMEOUT_ADDITION_MILLIS;
+                    final long startTimeMillis = System.currentTimeMillis();
+                    thread.join(timeToWaitMillis);
+                    if (System.currentTimeMillis() > startTimeMillis + 
timeToWaitMillis) {
+                        final String msg = "The stop timeout of " + 
timeoutMillis + " ms was exceeded";
                         caught = new ExecuteException(msg, 
Executor.INVALID_EXITVALUE);
                     }
                 }
diff --git a/src/main/java/org/apache/commons/exec/Watchdog.java 
b/src/main/java/org/apache/commons/exec/Watchdog.java
index b6e9ddc..eb32791 100644
--- a/src/main/java/org/apache/commons/exec/Watchdog.java
+++ b/src/main/java/org/apache/commons/exec/Watchdog.java
@@ -31,15 +31,15 @@ public class Watchdog implements Runnable {
 
     private final Vector<TimeoutObserver> observers = new Vector<>(1);
 
-    private final long timeout;
+    private final long timeoutMillis;
 
-    private boolean stopped = false;
+    private boolean stopped;
 
-    public Watchdog(final long timeout) {
-        if (timeout < 1) {
+    public Watchdog(final long timeoutMillis) {
+        if (timeoutMillis < 1) {
             throw new IllegalArgumentException("timeout must not be less than 
1.");
         }
-        this.timeout = timeout;
+        this.timeoutMillis = timeoutMillis;
     }
 
     public void addTimeoutObserver(final TimeoutObserver to) {
@@ -71,18 +71,18 @@ public class Watchdog implements Runnable {
 
     @Override
     public void run() {
-        final long startTime = System.currentTimeMillis();
+        final long startTimeMillis = System.currentTimeMillis();
         boolean isWaiting;
         synchronized (this) {
-            long timeLeft = timeout - (System.currentTimeMillis() - startTime);
-            isWaiting = timeLeft > 0;
+            long timeLeftMillis = timeoutMillis - (System.currentTimeMillis() 
- startTimeMillis);
+            isWaiting = timeLeftMillis > 0;
             while (!stopped && isWaiting) {
                 try {
-                    wait(timeLeft);
+                    wait(timeLeftMillis);
                 } catch (final InterruptedException e) {
                 }
-                timeLeft = timeout - (System.currentTimeMillis() - startTime);
-                isWaiting = timeLeft > 0;
+                timeLeftMillis = timeoutMillis - (System.currentTimeMillis() - 
startTimeMillis);
+                isWaiting = timeLeftMillis > 0;
             }
         }
 

Reply via email to