JDK-8156074 : write tests to verify proper null handling
  • Type: Sub-task
  • Component: core-libs
  • Sub-Component: java.util:collections
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2016-05-04
  • Updated: 2020-07-18
Description
Particularly for contains(null), and containsKey/containsValue for Maps.

The general rule seems to be, for collections that disallow nulls:

Queues and Deques: contains(null) returns false.

Sets: contains(null) throws NPE.

Maps: containsKey(null) and containsValue(null) throw NPE.

For unmodifiable collections tests, add:

 - List.containsAll(..., null, ...)
 - Set.containsAll(..., null, ...)
 - Map.getOrDefault(null, ...)
 - entrySet, keySet, and values views contains(null) and containsAll(..., null, ...)