Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ private static <K, V> Map<K, V> stringToMap(String strValue, Class<K> keyType, C
String[] tokens = trim(strValue).split(",");
Map<K, V> map = new HashMap<>();
for (String token : tokens) {
String[] keyValue = trim(token).split("=");
String[] keyValue = trim(token).split("=", 2);
checkArgument(keyValue.length == 2,
strValue + " map-value is not in correct format key1=value,key2=value2");
map.put(convert(trim(keyValue[0]), keyType), convert(trim(keyValue[1]), valueType));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@ public static class MyConfig {
public Set<String> stringSet;
}

@Test
public void testMapWithEqualsSignAndEmptyValue() {
Map<String, String> properties = new HashMap<>();
properties.put("stringStringMap", "key1=value=1,key2=");

MyConfig config = new MyConfig();
FieldParser.update(properties, config);

assertEquals(config.stringStringMap.get("key1"), "value=1");
assertEquals(config.stringStringMap.get("key2"), "");
}

@Test
public void testNullStrValue() throws Exception {
class TestMap {
Expand Down