This is an automated email from the ASF dual-hosted git repository.
nmalin pushed a commit to branch trunk
in repository
https://gitbox.apache.org/repos/asf/ofbiz-framework.gitThe following commit(s) were added to refs/heads/trunk by this push:
new 935ffe8 Fixed: Possible NPE in StringUtil#strToMap (OFBIZ-11281)
935ffe8 is described below
commit 935ffe86ca991ae0a1ed3e4f45c7f37006ca4a05
Author: Nicolas Malin <
[hidden email]>
AuthorDate: Thu Nov 14 09:10:05 2019 +0100
Fixed: Possible NPE in StringUtil#strToMap
(OFBIZ-11281)
StringUtil#strToMap(String, String, boolean, String) throws Nullpointer for StringUtil.strToMap("", false).
Thanks to Ulrich Heidfeld for this fix
---
framework/base/src/main/java/org/apache/ofbiz/base/util/StringUtil.java | 2 +-
.../base/src/test/java/org/apache/ofbiz/base/util/StringUtilTests.java | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/StringUtil.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/StringUtil.java
index ccb76f0..e7b97a5 100644
--- a/framework/base/src/main/java/org/apache/ofbiz/base/util/StringUtil.java
+++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/StringUtil.java
@@ -158,7 +158,7 @@ public class StringUtil {
* @return a Map of name/value pairs
*/
private static Map<String, String> strToMap(String str, String delim, boolean trim, String pairsSeparator) {
- if (str == null) {
+ if (UtilValidate.isEmpty(str)) {
return null;
}
Map<String, String> decodedMap = new HashMap<>();
diff --git a/framework/base/src/test/java/org/apache/ofbiz/base/util/StringUtilTests.java b/framework/base/src/test/java/org/apache/ofbiz/base/util/StringUtilTests.java
index d38b86e..48c1d2c 100644
--- a/framework/base/src/test/java/org/apache/ofbiz/base/util/StringUtilTests.java
+++ b/framework/base/src/test/java/org/apache/ofbiz/base/util/StringUtilTests.java
@@ -73,6 +73,7 @@ public class StringUtilTests {
@Test
public void testStrToMap() {
assertNull("null-string", StringUtil.strToMap(null, false));
+ assertNull("empty", StringUtil.strToMap("", false));
assertEquals("missing =", Collections.emptyMap(), StringUtil.strToMap("1", false));
assertEquals("single", UtilMisc.toMap("1", "one"), StringUtil.strToMap("1=one"));
assertEquals("double", UtilMisc.toMap("2", "two", "1", "one"), StringUtil.strToMap("1=one|2=two"));