RFR: 8021591 : (s) Additional explicit null checks

Mike Duigou mike.duigou at oracle.com
Tue Aug 27 22:56:23 UTC 2013

Hello all;

Here's an updated version of the patch which incorporates feedback and improves the tests (the reason for delay):


The substance of the patch is largely to add missing checks that the collection provided to removeAll()/retainAll() is not null. The specification of these methods in the Collection interface has always indicated that an NPE should be thrown if the passed collection was null. Historically various implementations were inconsistent about whether they threw the NPE if a null collection was passed. Some collections would throw the NPE, some would not. The intent of this patch is to improve consistency and since there were examples of the NPE being correctly thrown the most prudent approach seems to have all implementations throw the NPE. If there had been no examples of the NPE being thrown then it would have been more prudent to amend the interface spec to remove the NPE notice.

A few other inconsistencies around null handling were also resolved. Some unit tests issues were also cleaned up.


On Jul 26 2013, at 16:31 , Mike Duigou wrote:

> Hello all;
> This patch adds some missing checks for null that, according to interface contract, should be throwing NPE. It also improves the existing tests to check for these cases. 
> http://cr.openjdk.java.net/~mduigou/JDK-8021591/0/webrev/
> The changes to src/share/classes/java/util/concurrent/ConcurrentHashMap.java will be synchronized separately with the jsr166 workspace. They are part of this review to avoid test failures.
> Mike

More information about the core-libs-dev mailing list