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 98105c19d49e7bc22f8ad3d4e7ae3c19342c79d3 Author: Gary Gregory <[email protected]> AuthorDate: Sun Dec 31 08:40:46 2023 -0500 Avoid NullPointerException in MapUtils.prefix(Map, String) --- src/changes/changes.xml | 1 + .../java/org/apache/commons/exec/util/MapUtils.java | 5 ++--- src/site/resources/images/apache-commons-exec.png | Bin 0 -> 664955 bytes 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index fb478e99..6542c4e3 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -50,6 +50,7 @@ <action dev="ggregory" type="fix" due-to="Gary Gregory">Deprecate StringUtils.toString(String[], String) in favor of String.join(CharSequence, CharSequence...).</action> <action issue="EXEC-78" dev="ggregory" type="fix">No need to use System.class.getMethod("getenv",...) any more.</action> <action issue="EXEC-70" dev="ggregory" type="fix">Delegate thread creation to java.util.concurrent.ThreadFactory.</action> + <action dev="ggregory" type="fix" due-to="Gary Gregory">Avoid NullPointerException in MapUtils.prefix(Map, String).</action> <!-- REMOVE --> <action dev="ggregory" type="remove" due-to="Gary Gregory">Deprecate DefaultExecuteResultHandler.waitFor(long).</action> <action dev="ggregory" type="remove" due-to="Gary Gregory">Deprecate ExecuteWatchdog.ExecuteWatchdog(long).</action> 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 76048fba..cdf7eb35 100644 --- a/src/main/java/org/apache/commons/exec/util/MapUtils.java +++ b/src/main/java/org/apache/commons/exec/util/MapUtils.java @@ -19,6 +19,7 @@ package org.apache.commons.exec.util; import java.util.HashMap; import java.util.Map; +import java.util.Objects; /** * Helper classes to manipulate maps to pass substition map to the CommandLine. This class is not part of the public API and could change without warning. @@ -73,9 +74,7 @@ public class MapUtils { } final Map<String, V> result = new HashMap<>(); for (final Map.Entry<K, V> entry : source.entrySet()) { - final K key = entry.getKey(); - final V value = entry.getValue(); - result.put(prefix + '.' + key.toString(), value); + result.put(prefix + '.' + Objects.toString(entry.getKey(), ""), entry.getValue()); } return result; } diff --git a/src/site/resources/images/apache-commons-exec.png b/src/site/resources/images/apache-commons-exec.png new file mode 100644 index 00000000..0329c976 Binary files /dev/null and b/src/site/resources/images/apache-commons-exec.png differ
