JDK-6897166 : java.util.Objects.compare(...): unspecified NullPointerException for null comparator
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • OS: generic
  • CPU: generic
  • Submitted: 2009-11-02
  • Updated: 2011-01-19
  • Resolved: 2009-11-02
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
7Resolved
Related Reports
Relates :  
Description
The spec for java.util.Objects.compare(T a, T b, Comparator<? super T> c) should specify that the method throws NullPointerException if comparator is null.

Comments
EVALUATION The original specification of Objects.compare covers this case: "Returns 0 if the arguments are identical and c.compare(a, b) otherwise. Consequently, if both arguments are null 0 is returned." Therefore, if a and b are not both null, c.compare(a, b) is returned, which implies a NullPointerException would be thrown if c is null. Note that Objects.compare(null null, null) returns 0 as does Objects.compare("foo", "foo", null) Closing as not a bug.
02-11-2009