Skip to content

Commit

Permalink
fix null pointer exception for hasValue in a repeating group when the…
Browse files Browse the repository at this point in the history
…re is no value
  • Loading branch information
RyanHealey committed Feb 3, 2023
1 parent def9e9e commit 200a45d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ class RepeatingParamValues implements RepeatingGroup
@Override
public boolean hasValue(final String name)
{
return !getValues(name).isEmpty();
final List<String> values = getValues(name);
return !(values == null || values.isEmpty());

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import java.util.Map;

import static java.util.Arrays.asList;
import static java.util.Collections.emptyList;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
Expand Down Expand Up @@ -113,7 +112,6 @@ public void shouldNotReportOptionalValueAsPresentWhenNoValueProvided()
final OptionalArg otherArg = new OptionalArg("bar");
final Map<String, List<String>> values = new HashMap<>();
values.put("foo", Collections.singletonList("abc"));
values.put("bar", emptyList());
final RepeatingParamValues params = new RepeatingParamValues(asList(requiredArg, otherArg).toArray(new DslArg[0]), values);

assertFalse(params.hasValue("bar"));
Expand Down

0 comments on commit 200a45d

Please sign in to comment.