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 afa90ed7acc1b79d6fd160622a4347e1bf754dca Author: Gary D. Gregory <garydgreg...@gmail.com> AuthorDate: Sat May 24 10:05:08 2025 -0400 Remove some extra vertical whitespace --- src/main/java/org/apache/commons/exec/CommandLine.java | 16 ---------------- src/main/java/org/apache/commons/exec/Watchdog.java | 1 - 2 files changed, 17 deletions(-) diff --git a/src/main/java/org/apache/commons/exec/CommandLine.java b/src/main/java/org/apache/commons/exec/CommandLine.java index 9c20e946..1a7cbf3d 100644 --- a/src/main/java/org/apache/commons/exec/CommandLine.java +++ b/src/main/java/org/apache/commons/exec/CommandLine.java @@ -78,7 +78,6 @@ public class CommandLine { * @throws IllegalArgumentException If line is null or all whitespace. */ public static CommandLine parse(final String line, final Map<String, ?> substitutionMap) { - if (line == null) { throw new IllegalArgumentException("Command line cannot be null"); } @@ -86,13 +85,11 @@ public class CommandLine { throw new IllegalArgumentException("Command line cannot be empty"); } final String[] tmp = translateCommandline(line); - final CommandLine cl = new CommandLine(tmp[0]); cl.setSubstitutionMap(substitutionMap); for (int i = 1; i < tmp.length; i++) { cl.addArgument(tmp[i]); } - return cl; } @@ -107,9 +104,7 @@ public class CommandLine { // no command? no string return new String[0]; } - // parse with a simple finite state machine. - final int normal = 0; final int inQuote = 1; final int inDoubleQuote = 2; @@ -118,7 +113,6 @@ public class CommandLine { final ArrayList<String> list = new ArrayList<>(); StringBuilder current = new StringBuilder(); boolean lastTokenHasBeenQuoted = false; - while (tok.hasMoreTokens()) { final String nextTok = tok.nextToken(); switch (state) { @@ -160,15 +154,12 @@ public class CommandLine { break; } } - if (lastTokenHasBeenQuoted || current.length() != 0) { list.add(current.toString()); } - if (state == inQuote || state == inDoubleQuote) { throw new IllegalArgumentException("Unbalanced quotes in " + toProcess); } - final String[] args = new String[list.size()]; return list.toArray(args); } @@ -259,17 +250,14 @@ public class CommandLine { * @return The command line itself. */ public CommandLine addArgument(final String argument, final boolean handleQuoting) { - if (argument == null) { return this; } - // check if we can really quote the argument - if not throw an // IllegalArgumentException if (handleQuoting) { StringUtils.quoteArgument(argument); } - arguments.add(new Argument(argument, handleQuoting)); return this; } @@ -298,7 +286,6 @@ public class CommandLine { final String[] argumentsArray = translateCommandline(addArguments); addArguments(argumentsArray, handleQuoting); } - return this; } @@ -345,17 +332,14 @@ public class CommandLine { * @return The quoted arguments. */ public String[] getArguments() { - Argument currArgument; String expandedArgument; final String[] result = new String[arguments.size()]; - for (int i = 0; i < result.length; i++) { currArgument = arguments.get(i); expandedArgument = expandArgument(currArgument.getValue()); result[i] = currArgument.isHandleQuoting() ? StringUtils.quoteArgument(expandedArgument) : expandedArgument; } - return result; } diff --git a/src/main/java/org/apache/commons/exec/Watchdog.java b/src/main/java/org/apache/commons/exec/Watchdog.java index ac245677..9c36f2ae 100644 --- a/src/main/java/org/apache/commons/exec/Watchdog.java +++ b/src/main/java/org/apache/commons/exec/Watchdog.java @@ -171,7 +171,6 @@ public class Watchdog implements Runnable { isWaiting = timeLeftMillis > 0; } } - // notify the listeners outside of the synchronized block (see EXEC-60) if (!isWaiting) { fireTimeoutOccured();