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/13 13:35:51 UTC
(commons-exec) branch master updated: Code clean ups
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 5c207384 Code clean ups
5c207384 is described below
commit 5c207384d4e789f7df9a749a109c70baa0b72516
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Dec 13 08:35:47 2023 -0500
Code clean ups
- Use diamond notation
- Use better System API
- Make private class static
- Remove trailing whitespace
- Use compact arary declaration
---
src/main/java/org/apache/commons/exec/ExecuteException.java | 2 +-
src/main/java/org/apache/commons/exec/ProcessDestroyer.java | 2 +-
src/main/java/org/apache/commons/exec/util/StringUtils.java | 12 +++---------
src/test/java/org/apache/commons/exec/CommandLineTest.java | 2 +-
.../java/org/apache/commons/exec/DefaultExecutorTest.java | 2 +-
.../java/org/apache/commons/exec/LogOutputStreamTest.java | 2 +-
src/test/java/org/apache/commons/exec/TestUtil.java | 2 +-
7 files changed, 9 insertions(+), 15 deletions(-)
diff --git a/src/main/java/org/apache/commons/exec/ExecuteException.java b/src/main/java/org/apache/commons/exec/ExecuteException.java
index 225650af..5c39ea96 100644
--- a/src/main/java/org/apache/commons/exec/ExecuteException.java
+++ b/src/main/java/org/apache/commons/exec/ExecuteException.java
@@ -74,7 +74,7 @@ public class ExecuteException extends IOException {
/**
* Gets the exit value returned by the failed process
- *
+ *
* @return The exit value
*/
public int getExitValue() {
diff --git a/src/main/java/org/apache/commons/exec/ProcessDestroyer.java b/src/main/java/org/apache/commons/exec/ProcessDestroyer.java
index 291f2c7a..1277bf92 100644
--- a/src/main/java/org/apache/commons/exec/ProcessDestroyer.java
+++ b/src/main/java/org/apache/commons/exec/ProcessDestroyer.java
@@ -19,7 +19,7 @@ package org.apache.commons.exec;
/**
* Destroys all registered {@link Process} after a certain event, typically when the VM exits
- *
+ *
* @see org.apache.commons.exec.ShutdownHookProcessDestroyer
*/
public interface ProcessDestroyer {
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 a1966118..bdecf27f 100644
--- a/src/main/java/org/apache/commons/exec/util/StringUtils.java
+++ b/src/main/java/org/apache/commons/exec/util/StringUtils.java
@@ -31,7 +31,7 @@ import java.util.StringTokenizer;
*/
public class StringUtils {
- private static final String[] EMPTY_STRING_ARRAY = new String[0];
+ private static final String[] EMPTY_STRING_ARRAY = {};
private static final String SINGLE_QUOTE = "\'";
private static final String DOUBLE_QUOTE = "\"";
private static final char SLASH_CHAR = '/';
@@ -228,13 +228,7 @@ public class StringUtils {
* @return the concatenated strings
*/
public static String toString(final String[] strings, final String separator) {
- final StringBuilder sb = new StringBuilder();
- for (int i = 0; i < strings.length; i++) {
- if (i > 0) {
- sb.append(separator);
- }
- sb.append(strings[i]);
- }
- return sb.toString();
+ final String sb = String.join(separator, strings);
+ return sb;
}
}
\ No newline at end of file
diff --git a/src/test/java/org/apache/commons/exec/CommandLineTest.java b/src/test/java/org/apache/commons/exec/CommandLineTest.java
index 1475a77a..4d25a87f 100644
--- a/src/test/java/org/apache/commons/exec/CommandLineTest.java
+++ b/src/test/java/org/apache/commons/exec/CommandLineTest.java
@@ -183,7 +183,7 @@ public class CommandLineTest {
assertArrayEquals(new String[] { "${appMainClass}" }, cmdl.getArguments());
// pass arguments with an empty map
- cmdl = CommandLine.parse("${JAVA_HOME}/bin/java ${appMainClass}", new HashMap<String, Object>());
+ cmdl = CommandLine.parse("${JAVA_HOME}/bin/java ${appMainClass}", new HashMap<>());
assertTrue(cmdl.getExecutable().indexOf("${JAVA_HOME}") == 0);
assertArrayEquals(new String[] { "${appMainClass}" }, cmdl.getArguments());
diff --git a/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java b/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java
index 769b319e..2a386a88 100644
--- a/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java
+++ b/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java
@@ -148,7 +148,7 @@ public class DefaultExecutorTest {
final BufferedReader reader = new BufferedReader(new FileReader(file));
while ((text = reader.readLine()) != null) {
- contents.append(text).append(System.getProperty("line.separator"));
+ contents.append(text).append(System.lineSeparator());
}
reader.close();
return contents.toString();
diff --git a/src/test/java/org/apache/commons/exec/LogOutputStreamTest.java b/src/test/java/org/apache/commons/exec/LogOutputStreamTest.java
index 71298dfa..c999cbaa 100644
--- a/src/test/java/org/apache/commons/exec/LogOutputStreamTest.java
+++ b/src/test/java/org/apache/commons/exec/LogOutputStreamTest.java
@@ -35,7 +35,7 @@ import org.junit.Test;
*/
public class LogOutputStreamTest {
- private final class SystemLogOutputStream extends LogOutputStream {
+ private static final class SystemLogOutputStream extends LogOutputStream {
StringBuffer output = new StringBuffer();
diff --git a/src/test/java/org/apache/commons/exec/TestUtil.java b/src/test/java/org/apache/commons/exec/TestUtil.java
index 3d9d67d0..4ee7fed7 100644
--- a/src/test/java/org/apache/commons/exec/TestUtil.java
+++ b/src/test/java/org/apache/commons/exec/TestUtil.java
@@ -27,7 +27,7 @@ public final class TestUtil {
/**
* Gets success and fail return codes used by the test scripts
- *
+ *
* @return int array[2] = {ok, success}
*/
public static int[] getTestScriptCodesForOS() {