diff --git a/datashare-app/src/main/java/org/icij/datashare/session/HashMapUser.java b/datashare-app/src/main/java/org/icij/datashare/session/HashMapUser.java index c16636996..78ff6e048 100644 --- a/datashare-app/src/main/java/org/icij/datashare/session/HashMapUser.java +++ b/datashare-app/src/main/java/org/icij/datashare/session/HashMapUser.java @@ -53,8 +53,9 @@ public List getProjects() { } public Map 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)); } diff --git a/datashare-app/src/test/java/org/icij/datashare/session/HashMapUserTest.java b/datashare-app/src/test/java/org/icij/datashare/session/HashMapUserTest.java index 8b1a2cad7..87176d052 100644 --- a/datashare-app/src/test/java/org/icij/datashare/session/HashMapUserTest.java +++ b/datashare-app/src/test/java/org/icij/datashare/session/HashMapUserTest.java @@ -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());