Fix java time formatters that round up#37604
Merged
spinscale merged 11 commits intoelastic:masterfrom Jan 22, 2019
Merged
Conversation
In order to be able to parse epoch seconds and epoch milli seconds own java time fields had been introduced. These fields are however not compatible with the way that java time allows one to configure default fields (when a part of a timestamp cannot be read then a default value is added), which is used for the formatters that are rounding up to the next value. This gets even more problematic when the epoch formats are mixed with other formats like `strict_date_optional_time||epoch_second`, as this ends up in exceptions being thrown on parsing. This commit catches this corner case by implementing a special parse method for those rounding up formatters, that catches the exception and is calling `parseUnresolved` on the formatter, so that we can manually intervene and try to create a proper epoch based dates when the other parsing has failed. Also the formatter now properly copies the locale and the timezone.
Collaborator
|
Pinging @elastic/es-core-infra |
parsers. This also ensures all pre defined date formatters use nano seconds, even though the resolution might be smaller. The epoch formatters need different default parsers, which are configured in the ctor. Note: This is not yet the final result in terms of code.
danielmitterdorfer
approved these changes
Jan 21, 2019
Member
danielmitterdorfer
left a comment
There was a problem hiding this comment.
LGTM. I left one minor comment.
| return Joda.forPattern(input); | ||
| } | ||
|
|
||
| input = input.substring(1); |
Member
There was a problem hiding this comment.
This is to remove the leading "8" from the input pattern but I always find this confusing without a comment.
Contributor
Author
|
@elasticmachine run gradle build tests 2 |
spinscale
added a commit
to spinscale/elasticsearch
that referenced
this pull request
Jan 22, 2019
In order to be able to parse epoch seconds and epoch milli seconds own java time fields had been introduced. These fields are however not compatible with the way that java time allows one to configure default fields (when a part of a timestamp cannot be read then a default value is added), which is used for the formatters that are rounding up to the next value. This commit allows java date formatters to configure its round up parsing by setting default values via a consumer. By default all formats are setting JavaDateFormatter.ROUND_UP_BASE_FIELDS for rounding up. The epoch however parsers both need to set different fields. The merged date formatters do not set any fields, they just append all the round up formatters. Also the formatter now properly copies the locale and the timezone, fractional parsing has been set to nano seconds with proper width.
jasontedor
added a commit
to jasontedor/elasticsearch
that referenced
this pull request
Jan 22, 2019
* elastic/master: (43 commits) Remove remaining occurances of "include_type_name=true" in docs (elastic#37646) SQL: Return Intervals in SQL format for CLI (elastic#37602) Publish to masters first (elastic#37673) Un-assign persistent tasks as nodes exit the cluster (elastic#37656) Fail start of non-data node if node has data (elastic#37347) Use cancel instead of timeout for aborting publications (elastic#37670) Follow stats api should return a 404 when requesting stats for a non existing index (elastic#37220) Remove deprecated FieldNamesFieldMapper.Builder#index (elastic#37305) Document that date math is locale independent Bootstrap a Zen2 cluster once quorum is discovered (elastic#37463) Upgrade to lucene-8.0.0-snapshot-83f9835. (elastic#37668) Mute failing test Fix java time formatters that round up (elastic#37604) Removes awaits fix as the fix is in. (elastic#37676) Mute failing test Ensure that max seq # is equal to the global checkpoint when creating ReadOnlyEngines (elastic#37426) Mute failing discovery disruption tests Add note about how the body is referenced (elastic#33935) Define constants for REST requests endpoints in tests (elastic#37610) Make prepare engine step of recovery source non-blocking (elastic#37573) ...
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In order to be able to parse epoch seconds and epoch milli seconds own
java time fields had been introduced. These fields are however not
compatible with the way that java time allows one to configure default
fields (when a part of a timestamp cannot be read then a default value
is added), which is used for the formatters that are rounding up to the
next value.
This commit allows java date formatters to configure its round up parsing by setting any default values via a consumer. By default all formats are setting JavaDateFormatter.ROUND_UP_BASE_FIELDS for default parsing. The epoch parsers both set different fields and merged date formatters do not set any fields, because this has already been done in the concrete date formatters.
Also the formatter now properly copies the locale and the timezone, fractional parsing has been set to nano seconds with proper width.
Reviewers note: I plan to backport this in 7.0 and 6.7.