Skip to content

Commit

Permalink
[fix] NullPointerException on staging
Browse files Browse the repository at this point in the history
avoid null values in user hash map
  • Loading branch information
bamthomas committed Feb 27, 2020
1 parent 7b953b3 commit 9744a46
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ public List<String> getProjects() {
}

public Map<String, Object> getMap() {
return userMap.entrySet().stream().filter(
k -> !k.getKey().equalsIgnoreCase("password")).
return userMap.entrySet().stream().
filter(k -> k.getValue() != null).
filter(k -> !k.getKey().equalsIgnoreCase("password")).
collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public void test_from_json_null() {
assertThat(fromJson(null)).isNull();
}

@Test
public void test_getMap_with_null_value() {
assertThat(fromJson("{\"key\":null,\"array\":[]}").getMap()).isNotEmpty();
}

@Test
public void test_equals_with_user_subclass() {
assertThat(User.local()).isEqualTo(HashMapUser.local());
Expand Down

0 comments on commit 9744a46

Please sign in to comment.