JDK-8036818 : DateTimeFormatter withResolverFields() fails to accept null
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.time
  • Affected Version: 8
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2014-03-06
  • Updated: 2017-05-17
  • Resolved: 2014-04-05
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.
8u20Fixed 9 b08Fixed
This method is supposed to accept null to allow a copy of the formatter to be returned reset to the original state of having no resolver fields. The docs say:

"@param resolverFields  the new set of resolver fields, null if no fields"

which was written to indicate that resetting to null is permitted.

The fix is to check for null and return a copy of the formatter. Note that there are two variations of the method which need fixing.

This should be backported to 8u.
Failed JCK tests: api/java_time/tck/java/time/format/index.html#TCKDateTimeFormatter[test_resolverFields_Array_null] api/java_time/tck/java/time/format/index.html#TCKDateTimeFormatter[test_resolverFields_Set_null]

Attaching patch for IP reasons

Proposed patch: https://gist.github.com/jodastephen/9395197