Merge pull request #21 from apache/dependabot/github_actions/actions/setup-java-v1.4.3
Bump actions/setup-java from v1.4.0 to v1.4.3
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index 6720e14..3de6082 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -31,7 +31,7 @@
experimental: true
steps:
- - uses: actions/checkout@v2.3.2
+ - uses: actions/checkout@v2.3.4
- uses: actions/cache@v2
with:
path: ~/.m2/repository
diff --git a/.travis.yml b/.travis.yml
index 746c618..6be9ce7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -16,13 +16,10 @@
language: java
sudo: true
-# Required to build with openjdk7
-dist: trusty
-
jdk:
- - openjdk7
- openjdk8
- openjdk11
+ - openjdk15
script:
- mvn -V --no-transfer-progress -Ddoclint=all
diff --git a/SECURITY.md b/SECURITY.md
new file mode 100644
index 0000000..51943ba
--- /dev/null
+++ b/SECURITY.md
@@ -0,0 +1,17 @@
+<!---
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+The Apache Commons security page is [https://commons.apache.org/security.html](https://commons.apache.org/security.html).
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 72265e9..747877a 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -34,6 +34,9 @@
<action issue="EXEC-111" dev="ggregory" type="update" due-to="Gary Gregory">
Update Java requirement from Java 5 to 6.
</action>
+ <action dev="ggregory" type="update" due-to="Dependabot">
+ Bump actions/checkout from v2.3.2 to v2.3.4 #24.
+ </action>
</release>
<release version="1.3" date="2014-11-02" description="Maintenance and feature Release">
<action issue="EXEC-69" dev="ggregory" type="add" due-to="Richard Atkins, Michael Vorburger">
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 @@
/**
* 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 @@
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 @@
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 @@
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 @@
*/
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 @@
*/
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/launcher/VmsCommandLauncher.java b/src/main/java/org/apache/commons/exec/launcher/VmsCommandLauncher.java
index 019ffaa..8f0d28a 100644
--- a/src/main/java/org/apache/commons/exec/launcher/VmsCommandLauncher.java
+++ b/src/main/java/org/apache/commons/exec/launcher/VmsCommandLauncher.java
@@ -81,10 +81,7 @@
throws IOException {
final File script = File.createTempFile("EXEC", ".TMP");
script.deleteOnExit();
- PrintWriter out = null;
- try {
- out = new PrintWriter(new FileWriter(script.getAbsolutePath(),true));
-
+ try (PrintWriter out = new PrintWriter(new FileWriter(script.getAbsolutePath(),true))) {
// add the environment as global symbols for the DCL script
if (env != null) {
final Set<Entry<String, String>> entries = env.entrySet();
@@ -137,10 +134,6 @@
out.print(arg);
}
out.println();
- } finally {
- if (out != null) {
- out.close();
- }
}
return script;
}
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 @@
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 @@
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 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 @@
@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 @@
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 @@
// 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 @@
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 @@
@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 @@
@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 1bb4a27..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 @@
*/
@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);
@@ -615,16 +615,13 @@
final File outfile = File.createTempFile("EXEC", ".test");
outfile.deleteOnExit();
final CommandLine cl = new CommandLine(testScript);
- final FileOutputStream outAndErr = new FileOutputStream(outfile);
- try {
+ try (FileOutputStream outAndErr = new FileOutputStream(outfile)) {
final PumpStreamHandler pumpStreamHandler = new PumpStreamHandler(outAndErr);
final DefaultExecutor executor = new DefaultExecutor();
executor.setStreamHandler(pumpStreamHandler);
final int exitValue = executor.execute(cl);
assertFalse(exec.isFailure(exitValue));
assertTrue(outfile.exists());
- } finally {
- outAndErr.close();
}
}
@@ -692,7 +689,7 @@
*/
@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);
@@ -703,7 +700,7 @@
@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";
@@ -730,7 +727,7 @@
// 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);
@@ -741,7 +738,7 @@
// 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 @@
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 @@
// 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 @@
*/
@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 @@
*/
@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 @@
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 @@
@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 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 @@
@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 @@
@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 @@
@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 @@
@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 @@
@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());