forked from FasterXML/jackson-modules-java8
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only normalize OffsetDateTimes when they are normalizable
Fix for FasterXML#166. This commit introduces static constants for the minimum and the maximum OffsetDateTimes that are adjustable to all possible time zones in InstantDeserializer and adds a check that an OffsetDateTime lies in these boundaries before it is adjusted.
- Loading branch information
Showing
2 changed files
with
102 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In trying to think of a way around the 4 checks, and then realizing for majority of the time, the logic would short-circuit to only two checks, and also in keeping with @cowtowncoders point about preferring the simpler solution from the two originally proposed, wouldn't it be even simpler to just check MAX and MIN?
Here's the argument: If someone sets a date, and they have the
ADJUST_DATES_TO_CONTEXT_TIME_ZONE
set, then Jackson Java 8 will strive to meet that requirement, unless the date is set to a constant, like OffsetDateTime.MIN or OffsetDateTime.MAX. That would seem to keep the documentation* simpler, not only the logic. This change could safely go in 2.11.1, since it is fixing a bug, but with the normalization (i.e. MIN/MAX adjusted), would be a little safer to go in 2.12.Wondering** about the change from the 18 hour offset (original changes) to 36 hours with the new change set? Could there even be a case where the timezone isn't adjusted when it should be, with the 36 hour range? Found this in the documentation:
In summary, while I'd lean towards a more fine-tuned fix, I don't have a super-strongly held position on this. @cowtowncoder for the tie-breaker?
*Since this looks close to being ready (pending questions above), the documentation on the
ADJUST_DATES_TO_CONTEXT_TIME_ZONE
should be updated to reflect the new logic. This is one more plus for keeping the logic simpler, in that it's easier to explain in the documentation. If the user has a requirement to put in dates really close to the MIN/MAX ofOffsetDateTime
, then they'll need to set theADJUST_DATES_TO_CONTEXT_TIME_ZONE
flag to false.** I missed your explanation here, just went through my e-mail and see you explained it: