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 2020/11/21 15:55:37 UTC
[commons-exec] branch master updated: Use diamonds.
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 c1040ef Use diamonds.
c1040ef is described below
commit c1040ef92e2caf30234b9f0734798cf707b4904c
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Nov 21 10:55:33 2020 -0500
Use diamonds.
---
src/main/java/org/apache/commons/exec/CommandLine.java | 6 +++---
.../apache/commons/exec/ShutdownHookProcessDestroyer.java | 2 +-
src/main/java/org/apache/commons/exec/Watchdog.java | 2 +-
.../exec/environment/DefaultProcessingEnvironment.java | 4 ++--
src/main/java/org/apache/commons/exec/util/MapUtils.java | 4 ++--
.../java/org/apache/commons/exec/util/StringUtils.java | 2 +-
src/test/java/org/apache/commons/exec/CommandLineTest.java | 14 +++++++-------
.../java/org/apache/commons/exec/DefaultExecutorTest.java | 10 +++++-----
src/test/java/org/apache/commons/exec/TutorialTest.java | 2 +-
.../commons/exec/environment/EnvironmentUtilsTest.java | 6 +++---
.../java/org/apache/commons/exec/issues/Exec36Test.java | 2 +-
.../java/org/apache/commons/exec/util/MapUtilTest.java | 6 +++---
.../java/org/apache/commons/exec/util/StringUtilTest.java | 8 ++++----
13 files changed, 34 insertions(+), 34 deletions(-)
diff --git a/src/main/java/org/apache/commons/exec/CommandLine.java b/src/main/java/org/apache/commons/exec/CommandLine.java
index 579d14c..5a1882c 100644
--- a/src/main/java/org/apache/commons/exec/CommandLine.java
+++ b/src/main/java/org/apache/commons/exec/CommandLine.java
@@ -38,7 +38,7 @@ public class CommandLine {
/**
* The arguments of the command.
*/
- private final Vector<Argument> arguments = new Vector<Argument>();
+ private final Vector<Argument> arguments = new Vector<>();
/**
* The program to execute.
@@ -126,7 +126,7 @@ public class CommandLine {
if (other.getSubstitutionMap() != null)
{
- final Map<String, Object> omap = new HashMap<String, Object>();
+ final Map<String, Object> omap = new HashMap<>();
this.substitutionMap = omap;
final Iterator<String> iterator = other.substitutionMap.keySet().iterator();
while (iterator.hasNext())
@@ -346,7 +346,7 @@ public class CommandLine {
final int inDoubleQuote = 2;
int state = normal;
final StringTokenizer tok = new StringTokenizer(toProcess, "\"\' ", true);
- final ArrayList<String> list = new ArrayList<String>();
+ final ArrayList<String> list = new ArrayList<>();
StringBuilder current = new StringBuilder();
boolean lastTokenHasBeenQuoted = false;
diff --git a/src/main/java/org/apache/commons/exec/ShutdownHookProcessDestroyer.java b/src/main/java/org/apache/commons/exec/ShutdownHookProcessDestroyer.java
index 4fb501e..3a5d715 100644
--- a/src/main/java/org/apache/commons/exec/ShutdownHookProcessDestroyer.java
+++ b/src/main/java/org/apache/commons/exec/ShutdownHookProcessDestroyer.java
@@ -28,7 +28,7 @@ import java.util.Vector;
public class ShutdownHookProcessDestroyer implements ProcessDestroyer, Runnable {
/** the list of currently running processes */
- private final Vector<Process> processes = new Vector<Process>();
+ private final Vector<Process> processes = new Vector<>();
/** The thread registered at the JVM to execute the shutdown handler */
private ProcessDestroyerImpl destroyProcessThread = null;
diff --git a/src/main/java/org/apache/commons/exec/Watchdog.java b/src/main/java/org/apache/commons/exec/Watchdog.java
index e83c2ea..e405709 100644
--- a/src/main/java/org/apache/commons/exec/Watchdog.java
+++ b/src/main/java/org/apache/commons/exec/Watchdog.java
@@ -29,7 +29,7 @@ import java.util.Vector;
*/
public class Watchdog implements Runnable {
- private final Vector<TimeoutObserver> observers = new Vector<TimeoutObserver>(1);
+ private final Vector<TimeoutObserver> observers = new Vector<>(1);
private final long timeout;
diff --git a/src/main/java/org/apache/commons/exec/environment/DefaultProcessingEnvironment.java b/src/main/java/org/apache/commons/exec/environment/DefaultProcessingEnvironment.java
index c79f364..f1018c1 100644
--- a/src/main/java/org/apache/commons/exec/environment/DefaultProcessingEnvironment.java
+++ b/src/main/java/org/apache/commons/exec/environment/DefaultProcessingEnvironment.java
@@ -216,13 +216,13 @@ public class DefaultProcessingEnvironment {
*/
private Map<String, String> createEnvironmentMap() {
if (OS.isFamilyWindows()) {
- return new TreeMap<String, String>(new Comparator<String>() {
+ return new TreeMap<>(new Comparator<String>() {
public int compare(final String key0, final String key1) {
return key0.compareToIgnoreCase(key1);
}
});
}
- return new HashMap<String, String>();
+ return new HashMap<>();
}
}
diff --git a/src/main/java/org/apache/commons/exec/util/MapUtils.java b/src/main/java/org/apache/commons/exec/util/MapUtils.java
index 20cd12d..2dd6b6c 100644
--- a/src/main/java/org/apache/commons/exec/util/MapUtils.java
+++ b/src/main/java/org/apache/commons/exec/util/MapUtils.java
@@ -45,7 +45,7 @@ public class MapUtils
return null;
}
- final Map<K, V> result = new HashMap<K, V>();
+ final Map<K, V> result = new HashMap<>();
result.putAll(source);
return result;
}
@@ -70,7 +70,7 @@ public class MapUtils
return null;
}
- final Map<String, V> result = new HashMap<String, V>();
+ final Map<String, V> result = new HashMap<>();
for (final Map.Entry<K, V> entry : source.entrySet()) {
final K key = entry.getKey();
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 2f13d9b..7eaeb7d 100644
--- a/src/main/java/org/apache/commons/exec/util/StringUtils.java
+++ b/src/main/java/org/apache/commons/exec/util/StringUtils.java
@@ -164,7 +164,7 @@ public class StringUtils {
*/
public static String[] split(final String input, final String splitChar) {
final StringTokenizer tokens = new StringTokenizer(input, splitChar);
- final List<String> strList = new ArrayList<String>();
+ final List<String> strList = new ArrayList<>();
while (tokens.hasMoreTokens()) {
strList.add(tokens.nextToken());
}
diff --git a/src/test/java/org/apache/commons/exec/CommandLineTest.java b/src/test/java/org/apache/commons/exec/CommandLineTest.java
index 610e970..9ae4c97 100644
--- a/src/test/java/org/apache/commons/exec/CommandLineTest.java
+++ b/src/test/java/org/apache/commons/exec/CommandLineTest.java
@@ -258,7 +258,7 @@ public class CommandLineTest {
@Test
public void testParseComplexCommandLine1() {
final HashMap<String, String> substitutionMap =
- new HashMap<String, String>();
+ new HashMap<>();
substitutionMap.put("in", "source.jpg");
substitutionMap.put("out", "target.jpg");
final CommandLine cmdl = CommandLine.parse("cmd /C convert ${in} -resize \"\'500x> \'\" ${out}", substitutionMap);
@@ -351,14 +351,14 @@ public class CommandLineTest {
CommandLine cmdl;
final HashMap<String, Object> substitutionMap =
- new HashMap<String, Object>();
+ new HashMap<>();
substitutionMap.put("JAVA_HOME", "/usr/local/java");
substitutionMap.put("appMainClass", "foo.bar.Main");
substitutionMap.put("file1", new File("./pom.xml"));
substitutionMap.put("file2", new File(".\\temp\\READ ME.txt"));
final HashMap<String, String> incompleteMap =
- new HashMap<String, String>();
+ new HashMap<>();
incompleteMap.put("JAVA_HOME", "/usr/local/java");
// do not pass substitution map
@@ -401,7 +401,7 @@ public class CommandLineTest {
// build the user supplied parameters
final HashMap<String, String> substitutionMap =
- new HashMap<String, String>();
+ new HashMap<>();
substitutionMap.put("JAVA_HOME", "C:\\Programme\\jdk1.5.0_12");
substitutionMap.put("appMainClass", "foo.bar.Main");
@@ -448,7 +448,7 @@ public class CommandLineTest {
cmdl.addArgument("/p");
cmdl.addArgument("/h");
cmdl.addArgument("${file}", false);
- final HashMap<String, String> params = new HashMap<String, String>();
+ final HashMap<String, String> params = new HashMap<>();
params.put("file", "C:\\Document And Settings\\documents\\432432.pdf");
cmdl.setSubstitutionMap(params);
final String[] result = cmdl.toStrings();
@@ -466,7 +466,7 @@ public class CommandLineTest {
@Test
public void testToString() throws Exception {
CommandLine cmdl;
- final HashMap<String, String> params = new HashMap<String, String>();
+ final HashMap<String, String> params = new HashMap<>();
// use no arguments
cmdl = CommandLine.parse("AcroRd32.exe", params);
@@ -507,7 +507,7 @@ public class CommandLineTest {
@Test
public void testCopyConstructor()
{
- final Map<String, String> map = new HashMap<String, String>();
+ final Map<String, String> map = new HashMap<>();
map.put("bar", "bar");
final CommandLine other = new CommandLine("test");
other.addArgument("foo");
diff --git a/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java b/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java
index a098a4b..ce68900 100644
--- a/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java
+++ b/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java
@@ -155,7 +155,7 @@ public class DefaultExecutorTest {
*/
@Test
public void testExecuteWithSingleEnvironmentVariable() throws Exception {
- final Map<String, String> env = new HashMap<String, String>();
+ final Map<String, String> env = new HashMap<>();
env.put("TEST_ENV_VAR", "XYZ");
final CommandLine cl = new CommandLine(testScript);
@@ -689,7 +689,7 @@ public class DefaultExecutorTest {
*/
@Test
public void testAddEnvironmentVariables() throws Exception {
- final Map<String, String> myEnvVars = new HashMap<String, String>();
+ final Map<String, String> myEnvVars = new HashMap<>();
myEnvVars.putAll(EnvironmentUtils.getProcEnvironment());
myEnvVars.put("NEW_VAR","NEW_VAL");
exec.execute(new CommandLine(environmentSript), myEnvVars);
@@ -700,7 +700,7 @@ public class DefaultExecutorTest {
@Test
public void testAddEnvironmentVariableEmbeddedQuote() throws Exception {
- final Map<String, String> myEnvVars = new HashMap<String, String>();
+ final Map<String, String> myEnvVars = new HashMap<>();
myEnvVars.putAll(EnvironmentUtils.getProcEnvironment());
final String name = "NEW_VAR";
final String value = "NEW_\"_VAL";
@@ -727,7 +727,7 @@ public class DefaultExecutorTest {
// make a plain-vanilla test
for (int i=0; i<100; i++) {
- final Map<String, String> env = new HashMap<String, String>();
+ final Map<String, String> env = new HashMap<>();
env.put("TEST_ENV_VAR", Integer.toString(i));
final CommandLine cl = new CommandLine(testScript);
final int exitValue = exec.execute(cl,env);
@@ -738,7 +738,7 @@ public class DefaultExecutorTest {
// now be nasty and use the watchdog to kill out sub-processes
for (int i=0; i<100; i++) {
- final Map<String, String> env = new HashMap<String, String>();
+ final Map<String, String> env = new HashMap<>();
env.put("TEST_ENV_VAR", Integer.toString(i));
final DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
final CommandLine cl = new CommandLine(foreverTestScript);
diff --git a/src/test/java/org/apache/commons/exec/TutorialTest.java b/src/test/java/org/apache/commons/exec/TutorialTest.java
index b18d041..20bae1b 100644
--- a/src/test/java/org/apache/commons/exec/TutorialTest.java
+++ b/src/test/java/org/apache/commons/exec/TutorialTest.java
@@ -88,7 +88,7 @@ public class TutorialTest {
PrintResultHandler resultHandler;
// build up the command line to using a 'java.io.File'
- final Map<String, File> map = new HashMap<String, File>();
+ final Map<String, File> map = new HashMap<>();
map.put("file", file);
final CommandLine commandLine = new CommandLine(acroRd32Script);
commandLine.addArgument("/p");
diff --git a/src/test/java/org/apache/commons/exec/environment/EnvironmentUtilsTest.java b/src/test/java/org/apache/commons/exec/environment/EnvironmentUtilsTest.java
index aa45bad..f969b81 100644
--- a/src/test/java/org/apache/commons/exec/environment/EnvironmentUtilsTest.java
+++ b/src/test/java/org/apache/commons/exec/environment/EnvironmentUtilsTest.java
@@ -47,7 +47,7 @@ public class EnvironmentUtilsTest {
// check for a non-existing environment when passing null
assertNull(EnvironmentUtils.toStrings(null));
// check for an environment when filling in two variables
- final Map<String, String> env = new HashMap<String, String>();
+ final Map<String, String> env = new HashMap<>();
assertArrayEquals(new String[0], EnvironmentUtils.toStrings(env));
env.put("foo2", "bar2");
env.put("foo", "bar");
@@ -132,7 +132,7 @@ public class EnvironmentUtilsTest {
*/
@Test
public void testToStringWithNullKey() {
- final Map<String, String> env = new HashMap<String, String>();
+ final Map<String, String> env = new HashMap<>();
env.put(null, "TheNullKey");
final String[] strings = EnvironmentUtils.toStrings(env);
assertEquals(1, strings.length);
@@ -145,7 +145,7 @@ public class EnvironmentUtilsTest {
*/
@Test
public void testToStringWithNullValue() {
- final Map<String, String> env = new HashMap<String, String>();
+ final Map<String, String> env = new HashMap<>();
env.put("key", null);
final String[] strings = EnvironmentUtils.toStrings(env);
assertEquals(1, strings.length);
diff --git a/src/test/java/org/apache/commons/exec/issues/Exec36Test.java b/src/test/java/org/apache/commons/exec/issues/Exec36Test.java
index 95bd09b..f0e59bd 100644
--- a/src/test/java/org/apache/commons/exec/issues/Exec36Test.java
+++ b/src/test/java/org/apache/commons/exec/issues/Exec36Test.java
@@ -138,7 +138,7 @@ public class Exec36Test {
CommandLine cmdl;
final File file = new File("/Documents and Settings/myusername/Local Settings/Temp/netfx.log");
- final Map<String, File> map = new HashMap<String, File>();
+ final Map<String, File> map = new HashMap<>();
map.put("FILE", file);
cmdl = new CommandLine(printArgsScript);
diff --git a/src/test/java/org/apache/commons/exec/util/MapUtilTest.java b/src/test/java/org/apache/commons/exec/util/MapUtilTest.java
index 3dfc2e6..af1a54d 100644
--- a/src/test/java/org/apache/commons/exec/util/MapUtilTest.java
+++ b/src/test/java/org/apache/commons/exec/util/MapUtilTest.java
@@ -36,7 +36,7 @@ public class MapUtilTest {
@Test
public void testCopyMap() throws Exception {
- final HashMap<String, String> procEnvironment = new HashMap<String, String>();
+ final HashMap<String, String> procEnvironment = new HashMap<>();
procEnvironment.put("JAVA_HOME", "/usr/opt/java");
final Map<String, String> result = MapUtils.copy(procEnvironment);
@@ -56,7 +56,7 @@ public class MapUtilTest {
public void testMergeMap() throws Exception {
final Map<String, String> procEnvironment = EnvironmentUtils.getProcEnvironment();
- final HashMap<String, String> applicationEnvironment = new HashMap<String, String>();
+ final HashMap<String, String> applicationEnvironment = new HashMap<>();
applicationEnvironment.put("appMainClass", "foo.bar.Main");
final Map<String, String> result = MapUtils.merge(procEnvironment, applicationEnvironment);
@@ -70,7 +70,7 @@ public class MapUtilTest {
@Test
public void testPrefixMap() throws Exception {
- final HashMap<String, String> procEnvironment = new HashMap<String, String>();
+ final HashMap<String, String> procEnvironment = new HashMap<>();
procEnvironment.put("JAVA_HOME", "/usr/opt/java");
final Map<String, String> result =
diff --git a/src/test/java/org/apache/commons/exec/util/StringUtilTest.java b/src/test/java/org/apache/commons/exec/util/StringUtilTest.java
index ec095cb..1745a3f 100644
--- a/src/test/java/org/apache/commons/exec/util/StringUtilTest.java
+++ b/src/test/java/org/apache/commons/exec/util/StringUtilTest.java
@@ -35,7 +35,7 @@ public class StringUtilTest {
@Test
public void testNoStringSubstitution() throws Exception
{
- final Map<String, String> vars = new HashMap<String, String>();
+ final Map<String, String> vars = new HashMap<>();
vars.put("foo", "FOO");
vars.put("bar", "BAR");
@@ -49,7 +49,7 @@ public class StringUtilTest {
@Test
public void testDefaultStringSubstitution() throws Exception
{
- final Map<String, String> vars = new HashMap<String, String>();
+ final Map<String, String> vars = new HashMap<>();
vars.put("foo", "FOO");
vars.put("bar", "BAR");
@@ -64,7 +64,7 @@ public class StringUtilTest {
@Test
public void testIncompleteSubstitution() throws Exception {
- final Map<String, String> vars = new HashMap<String, String>();
+ final Map<String, String> vars = new HashMap<>();
vars.put("foo", "FOO");
assertEquals("This is a FOO & ${bar} test", StringUtils.stringSubstitution("This is a ${foo} & ${bar} test", vars, true).toString());
@@ -86,7 +86,7 @@ public class StringUtilTest {
@Test
public void testErroneousTemplate() throws Exception
{
- final Map<String, String> vars = new HashMap<String, String>();
+ final Map<String, String> vars = new HashMap<>();
vars.put("foo", "FOO");
assertEquals("This is a FOO & ${}} test", StringUtils.stringSubstitution("This is a ${foo} & ${}} test", vars, true).toString());