Skip to content
Merged
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 @@ -105,4 +105,24 @@ public class UtilsTest {
when(context.checkCallingOrSelfPermission(ACCESS_NETWORK_STATE)).thenReturn(PERMISSION_DENIED);
assertThat(isConnected(context)).isTrue();
}

@Test public void nullableConcurrentHashMapPutIgnoresNulls() throws Exception {
Map<String, String> map = new Utils.NullableConcurrentHashMap<>();
map.put(null, null);
map.put("foo", null);
map.put(null, "bar");

assertThat(map).isEmpty();
}

@Test public void nullableConcurrentHashMapPutAllIgnoresNulls() throws Exception {
Map<String, String> values = new LinkedHashMap<>();
values.put(null, null);
values.put("foo", null);
values.put(null, "bar");

Map<String, String> map = new Utils.NullableConcurrentHashMap<>();
map.putAll(values);
assertThat(map).isEmpty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -426,5 +426,11 @@ public NullableConcurrentHashMap(Map<? extends K, ? extends V> m) {
}
return super.put(key, value);
}

@Override public void putAll(Map<? extends K, ? extends V> m) {
for (Map.Entry<? extends K, ? extends V> e : m.entrySet()) {
put(e.getKey(), e.getValue());
}
}
}
}