JDK-7173432 : Fix issue with null key at resize of HashMap
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:collections
  • Affected Version: 7-pool,8
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2012-06-01
  • Updated: 2021-03-03
  • Resolved: 2012-06-25
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7 JDK 8
7u6Fixed 8 b43Fixed
Description
If the key to be insterted into a HashMap is null and the table needs to be resized as part of the insertion then addEntry will try to recalculate the hash of a null key. This will fail with an NPE.

Comments
WORK AROUND http://hg.openjdk.java.net/jdk8/tl/jdk/rev/7baa22e6a6b3
01-06-2012

WORK AROUND http://hg.openjdk.java.net/jdk7u/jdk7u-dev/jdk/rev/421b71e31687
01-06-2012

SUGGESTED FIX as per evaulation
01-06-2012

EVALUATION use the same logic for calls to hash() as elsewhere: hash = (null != key) ? hash(key) : 0;
01-06-2012