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 008804a997fb6dc25b392f9fc5a5495674cf125a Author: Gary D. Gregory <garydgreg...@gmail.com> AuthorDate: Sat May 24 10:33:35 2025 -0400 Fix Checkstyle JavadocVariable - inline redundant constant --- src/conf/checkstyle-suppressions.xml | 1 + src/conf/checkstyle.xml | 4 +--- .../java/org/apache/commons/exec/CommandLine.java | 7 +++++++ .../org/apache/commons/exec/DefaultExecutor.java | 11 +++++++++++ .../org/apache/commons/exec/ExecuteWatchdog.java | 3 +++ .../org/apache/commons/exec/LogOutputStream.java | 9 +++++++++ src/main/java/org/apache/commons/exec/OS.java | 20 +++++++++++++++++--- .../org/apache/commons/exec/PumpStreamHandler.java | 12 ++++++++++++ .../commons/exec/ShutdownHookProcessDestroyer.java | 3 +++ src/main/java/org/apache/commons/exec/Watchdog.java | 14 ++++++++++++++ .../commons/exec/environment/EnvironmentUtils.java | 3 +++ .../org/apache/commons/exec/util/StringUtils.java | 9 +++++++++ 12 files changed, 90 insertions(+), 6 deletions(-) diff --git a/src/conf/checkstyle-suppressions.xml b/src/conf/checkstyle-suppressions.xml index 0f6721d6..102cb60d 100644 --- a/src/conf/checkstyle-suppressions.xml +++ b/src/conf/checkstyle-suppressions.xml @@ -21,6 +21,7 @@ limitations under the License. <!-- SEE: http://checkstyle.sourceforge.net/config.html#Examples --> <suppressions> <suppress checks="JavadocPackage" files="src[/\\]test[/\\]java[/\\]" /> + <suppress checks="JavadocVariable" files="src[/\\]test[/\\]java[/\\]" /> <!-- EnvironmentUtils can be final when we break BC. --> <suppress checks="FinalClass" files="src[/\\]main[/\\]java[/\\]org[/\\]apache[/\\]commons[/\\]exec[/\\]environment[/\\]EnvironmentUtils.java" /> <!-- StringUtils can have a private default constructor when we break BC. --> diff --git a/src/conf/checkstyle.xml b/src/conf/checkstyle.xml index 2559dab4..affff048 100644 --- a/src/conf/checkstyle.xml +++ b/src/conf/checkstyle.xml @@ -63,9 +63,7 @@ <!-- See https://checkstyle.sf.net/config_javadoc.html --> <module name="JavadocType"> </module> - <module name="JavadocVariable"> - <property name="accessModifiers" value="public, protected"/> - </module> + <module name="JavadocVariable" /> <!-- Checks for Naming Conventions. --> <!-- See https://checkstyle.sf.net/config_naming.html --> <module name="ConstantName" /> diff --git a/src/main/java/org/apache/commons/exec/CommandLine.java b/src/main/java/org/apache/commons/exec/CommandLine.java index 1a7cbf3d..c526a782 100644 --- a/src/main/java/org/apache/commons/exec/CommandLine.java +++ b/src/main/java/org/apache/commons/exec/CommandLine.java @@ -41,7 +41,14 @@ public class CommandLine { */ static final class Argument { + /** + * Argument value. + */ private final String value; + + /** + * Whether to quote arguments. + */ private final boolean handleQuoting; private Argument(final String value, final boolean handleQuoting) { diff --git a/src/main/java/org/apache/commons/exec/DefaultExecutor.java b/src/main/java/org/apache/commons/exec/DefaultExecutor.java index f9ceae74..e970c983 100644 --- a/src/main/java/org/apache/commons/exec/DefaultExecutor.java +++ b/src/main/java/org/apache/commons/exec/DefaultExecutor.java @@ -62,8 +62,19 @@ public class DefaultExecutor implements Executor { */ public static class Builder<T extends Builder<T>> implements Supplier<DefaultExecutor> { + /** + * Error stream handler. + */ private ExecuteStreamHandler executeStreamHandler; + + /** + * Thread factory. + */ private ThreadFactory threadFactory; + + /** + * Working directory path. + */ private Path workingDirectory; /** diff --git a/src/main/java/org/apache/commons/exec/ExecuteWatchdog.java b/src/main/java/org/apache/commons/exec/ExecuteWatchdog.java index 4130ea5f..f11f72e5 100644 --- a/src/main/java/org/apache/commons/exec/ExecuteWatchdog.java +++ b/src/main/java/org/apache/commons/exec/ExecuteWatchdog.java @@ -60,7 +60,10 @@ public class ExecuteWatchdog implements TimeoutObserver { */ public static final class Builder implements Supplier<ExecuteWatchdog> { + /** Thread factory. */ private ThreadFactory threadFactory; + + /** Timeout duration. */ private Duration timeout; /** diff --git a/src/main/java/org/apache/commons/exec/LogOutputStream.java b/src/main/java/org/apache/commons/exec/LogOutputStream.java index ad2edf85..0026578a 100644 --- a/src/main/java/org/apache/commons/exec/LogOutputStream.java +++ b/src/main/java/org/apache/commons/exec/LogOutputStream.java @@ -52,10 +52,19 @@ public abstract class LogOutputStream extends OutputStream { /** The internal buffer. */ private final ByteArrayOutputStreamX buffer = new ByteArrayOutputStreamX(INTIAL_SIZE); + /** + * Last written char was a CR. + */ private boolean skip; + /** + * Level used to log data written to this stream. + */ private final int level; + /** + * Character Set to use when processing lines. + */ private final Charset charset; /** diff --git a/src/main/java/org/apache/commons/exec/OS.java b/src/main/java/org/apache/commons/exec/OS.java index 9d6a803b..bb158eaf 100644 --- a/src/main/java/org/apache/commons/exec/OS.java +++ b/src/main/java/org/apache/commons/exec/OS.java @@ -89,12 +89,25 @@ public final class OS { */ public static final String FAMILY_ZOS = "z/os"; + /** + * Apple Darwin string: {@value} + */ private static final String DARWIN = "darwin"; + /** + * The OS name. + */ private static final String OS_NAME = System.getProperty("os.name").toLowerCase(Locale.ROOT); + + /** + * The OS architecture. + */ private static final String OS_ARCH = System.getProperty("os.arch").toLowerCase(Locale.ROOT); + + /** + * The OS version. + */ private static final String OS_VERSION = System.getProperty("os.version").toLowerCase(Locale.ROOT); - private static final String PATH_SEP = File.pathSeparator; /** * Tests whether the OS on which commons-exec is executing matches the given OS architecture. @@ -280,7 +293,7 @@ public final class OS { isFamily = OS_NAME.contains(FAMILY_NETWARE); break; case FAMILY_DOS: - isFamily = PATH_SEP.equals(";") && !isFamily(FAMILY_NETWARE); + isFamily = File.pathSeparator.equals(";") && !isFamily(FAMILY_NETWARE); break; case FAMILY_MAC: isFamily = OS_NAME.contains(FAMILY_MAC) || OS_NAME.contains(DARWIN); @@ -289,7 +302,8 @@ public final class OS { isFamily = OS_NAME.contains("nonstop_kernel"); break; case FAMILY_UNIX: - isFamily = PATH_SEP.equals(":") && !isFamily(FAMILY_VMS) && (!isFamily(FAMILY_MAC) || OS_NAME.endsWith("x") || OS_NAME.contains(DARWIN)); + isFamily = File.pathSeparator.equals(":") && !isFamily(FAMILY_VMS) + && (!isFamily(FAMILY_MAC) || OS_NAME.endsWith("x") || OS_NAME.contains(DARWIN)); break; case FAMILY_ZOS: isFamily = OS_NAME.contains(FAMILY_ZOS) || OS_NAME.contains("os/390"); diff --git a/src/main/java/org/apache/commons/exec/PumpStreamHandler.java b/src/main/java/org/apache/commons/exec/PumpStreamHandler.java index 3bb23dbc..51c2cb86 100644 --- a/src/main/java/org/apache/commons/exec/PumpStreamHandler.java +++ b/src/main/java/org/apache/commons/exec/PumpStreamHandler.java @@ -36,20 +36,32 @@ import org.apache.commons.exec.util.DebugUtils; */ public class PumpStreamHandler implements ExecuteStreamHandler { + /** Three seconds timeout. */ private static final Duration STOP_TIMEOUT_ADDITION = Duration.ofSeconds(2); + /** + * Output thread. + */ private Thread outputThread; + /** + * Error thread. + */ private Thread errorThread; + /** Input thread. */ private Thread inputThread; + /** Output stream. */ private final OutputStream outputStream; + /** Error output stream. */ private final OutputStream errorOutputStream; + /** Error input stream. */ private final InputStream inputStream; + /** Pumper input stream. */ private InputStreamPumper inputStreamPumper; /** The timeout Duration the implementation waits when stopping the pumper threads. */ diff --git a/src/main/java/org/apache/commons/exec/ShutdownHookProcessDestroyer.java b/src/main/java/org/apache/commons/exec/ShutdownHookProcessDestroyer.java index ec823e5e..63fd00c1 100644 --- a/src/main/java/org/apache/commons/exec/ShutdownHookProcessDestroyer.java +++ b/src/main/java/org/apache/commons/exec/ShutdownHookProcessDestroyer.java @@ -30,6 +30,9 @@ public class ShutdownHookProcessDestroyer implements ProcessDestroyer, Runnable private final class ProcessDestroyerThread extends Thread { + /** + * Whether to run the ShutdownHookProcessDestroyer. + */ private AtomicBoolean shouldDestroy = new AtomicBoolean(true); private ProcessDestroyerThread() { diff --git a/src/main/java/org/apache/commons/exec/Watchdog.java b/src/main/java/org/apache/commons/exec/Watchdog.java index 9c36f2ae..60ef82b7 100644 --- a/src/main/java/org/apache/commons/exec/Watchdog.java +++ b/src/main/java/org/apache/commons/exec/Watchdog.java @@ -39,7 +39,12 @@ public class Watchdog implements Runnable { */ public static final class Builder implements Supplier<Watchdog> { + /** Thread factory. */ private ThreadFactory threadFactory; + + /** + * Timeout duration. + */ private Duration timeout; /** @@ -93,10 +98,19 @@ public class Watchdog implements Runnable { return new Builder(); } + /** + * Observers. + */ private final List<TimeoutObserver> observers = new Vector<>(1); + /** + * Timeout duration. + */ private final long timeoutMillis; + /** + * Whether this is stopped. + */ private boolean stopped; /** diff --git a/src/main/java/org/apache/commons/exec/environment/EnvironmentUtils.java b/src/main/java/org/apache/commons/exec/environment/EnvironmentUtils.java index 9c297869..8f5e6e20 100644 --- a/src/main/java/org/apache/commons/exec/environment/EnvironmentUtils.java +++ b/src/main/java/org/apache/commons/exec/environment/EnvironmentUtils.java @@ -28,6 +28,9 @@ import java.util.Objects; */ public class EnvironmentUtils { + /** + * Default environment. + */ private static final DefaultProcessingEnvironment ENVIRONMENT; static { diff --git a/src/main/java/org/apache/commons/exec/util/StringUtils.java b/src/main/java/org/apache/commons/exec/util/StringUtils.java index 1016b5ac..90322eca 100644 --- a/src/main/java/org/apache/commons/exec/util/StringUtils.java +++ b/src/main/java/org/apache/commons/exec/util/StringUtils.java @@ -33,10 +33,19 @@ import java.util.StringTokenizer; */ public class StringUtils { + /** Empty array. */ private static final String[] EMPTY_STRING_ARRAY = {}; + + /** Single quote. */ private static final String SINGLE_QUOTE = "\'"; + + /** Double quote. */ private static final String DOUBLE_QUOTE = "\""; + + /** Forward lash character. */ private static final char SLASH_CHAR = '/'; + + /** Backlash character. */ private static final char BACKSLASH_CHAR = '\\'; /**