Skip to content

Commit 058db57

Browse files
committed
fix null pointer exception for hasValue in a repeating group when there is no value
1 parent 27f04ef commit 058db57

2 files changed

Lines changed: 2 additions & 3 deletions

File tree

src/main/java/com/lmax/simpledsl/internal/RepeatingParamValues.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ class RepeatingParamValues implements RepeatingGroup
2222
@Override
2323
public boolean hasValue(final String name)
2424
{
25-
return !getValues(name).isEmpty();
25+
final List<String> values = getValues(name);
26+
return !(values == null || values.isEmpty());
2627

2728
}
2829

src/test/java/com/lmax/simpledsl/internal/RepeatingParamValuesTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import java.util.Map;
2828

2929
import static java.util.Arrays.asList;
30-
import static java.util.Collections.emptyList;
3130
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
3231
import static org.junit.jupiter.api.Assertions.assertEquals;
3332
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -84,7 +83,6 @@ public void shouldNotReportOptionalValueAsPresentWhenNoValueProvided()
8483
final OptionalArg otherArg = new OptionalArg("bar");
8584
final Map<String, List<String>> values = new HashMap<>();
8685
values.put("foo", Collections.singletonList("abc"));
87-
values.put("bar", emptyList());
8886
final RepeatingParamValues params = new RepeatingParamValues(asList(requiredArg, otherArg).toArray(new DslArg[0]), values);
8987

9088
assertFalse(params.hasValue("bar"));

0 commit comments

Comments
 (0)