[prev in list] [next in list] [prev in thread] [next in thread]
List: jakarta-commons-dev
Subject: [commons-exec] branch master updated: Init Maps on creation.
From: ggregory () apache ! org
Date: 2021-02-28 15:32:15
Message-ID: 161452633502.24941.11857836064801442774 () gitbox ! apache ! org
[Download RAW message or body]
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 ce7da84 Init Maps on creation.
ce7da84 is described below
commit ce7da84482ae133e80d7051d13c21f9ce32ae856
Author: Gary Gregory <garydgregory@gmail.com>
AuthorDate: Sun Feb 28 10:32:11 2021 -0500
Init Maps on creation.
---
src/main/java/org/apache/commons/exec/util/MapUtils.java | 11 ++---------
.../java/org/apache/commons/exec/DefaultExecutorTest.java | 6 ++----
2 files changed, 4 insertions(+), 13 deletions(-)
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 cead70d..5d01aee \
100644
--- a/src/main/java/org/apache/commons/exec/util/MapUtils.java
+++ b/src/main/java/org/apache/commons/exec/util/MapUtils.java
@@ -39,15 +39,8 @@ public class MapUtils
* the map value type
* @return the cloned map
*/
- public static <K, V> Map<K, V> copy(final Map<K, V> source) {
-
- if (source == null) {
- return null;
- }
-
- final Map<K, V> result = new HashMap<>();
- result.putAll(source);
- return result;
+ public static <K, V> Map<K, V> copy(final Map<K, V> source) {
+ return source == null ? null : new HashMap<>(source);
}
/**
diff --git a/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java \
b/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java index \
c58b929..5d0402f 100644
--- a/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java
+++ b/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java
@@ -687,8 +687,7 @@ public class DefaultExecutorTest {
*/
@Test
public void testAddEnvironmentVariables() throws Exception {
- final Map<String, String> myEnvVars = new HashMap<>();
- myEnvVars.putAll(EnvironmentUtils.getProcEnvironment());
+ final Map<String, String> myEnvVars = new \
HashMap<>(EnvironmentUtils.getProcEnvironment()); \
myEnvVars.put("NEW_VAR","NEW_VAL"); exec.execute(new CommandLine(environmentSript), \
myEnvVars); final String environment = baos.toString().trim();
@@ -698,8 +697,7 @@ public class DefaultExecutorTest {
@Test
public void testAddEnvironmentVariableEmbeddedQuote() throws Exception {
- final Map<String, String> myEnvVars = new HashMap<>();
- myEnvVars.putAll(EnvironmentUtils.getProcEnvironment());
+ final Map<String, String> myEnvVars = new \
HashMap<>(EnvironmentUtils.getProcEnvironment()); final String name = "NEW_VAR";
final String value = "NEW_\"_VAL";
myEnvVars.put(name,value);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic