Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrating from joda to java.time. Watcher plugin #35809

Merged
merged 191 commits into from
Feb 4, 2019

Conversation

pgomulka
Copy link
Contributor

@pgomulka pgomulka commented Nov 22, 2018

part of the migrating joda time work.
migration watcher plugin to use JDK's java-time

refers #27330

This commit moves the aggregation and mapping code from joda time to
java time.

This includes field mappers, root object mappers, aggregations with date
histograms, query builders and a lot of changes within tests.
@@ -298,6 +298,8 @@ public void testSingleValuedFieldNormalised_timeZone_CET_DstEnd() throws Excepti
* also check for time zone shifts that are not one hour, e.g.
* "Asia/Kathmandu, 1 Jan 1986 - Time Zone Change (IST → NPT), at 00:00:00 clocks were turned forward 00:15 minutes
*/
// This test fails because we cannot parse negative epoch milli seconds yet... but perhaps we dont have to if we use instants in the
// rangefield method?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did this change sneak in ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should not be here (old comment, not in master). will remove


public class WatchStatusTests extends ESTestCase {

public void testAckStatusIsResetOnUnmetCondition() {
HashMap<String, ActionStatus> myMap = new HashMap<>();
ActionStatus actionStatus = new ActionStatus(now());
ActionStatus actionStatus = new ActionStatus(ZonedDateTime.now());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know these are only tests, but we can we avoid using the default TZ ? For anyone that looks at the unit tests for examples, this can lead to bugs.

Copy link
Contributor Author

@pgomulka pgomulka Jan 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, good advice. I will change this and another test in this PR that is also missing this

@jakelandis
Copy link
Contributor

Overall this change looks good a couple small comments.

However a broader question, (not suggesting that we do this now), why do we pass a ZonedDateTime around everywhere if we only care about UTC timezone ? I would think that passing around LocaleDateTime and only add the UTC timezone information when/where needed (like for serialization) would be more accurate and less prone to bugs.

@pgomulka
Copy link
Contributor Author

pgomulka commented Feb 1, 2019

personally I feel a bit safer knowing that all the dates used around are in UTC. Not entirely sure which places you have in mind where LocalDateTime would be better suited? Definitely worth discussing and refactoring in a next PR.

Copy link
Contributor

@jakelandis jakelandis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

thanks for the updates and tackling this large chunk of code.

@@ -196,7 +195,9 @@ public static Email parse(XContentParser parser) throws IOException{
} else if (Field.PRIORITY.match(currentFieldName, parser.getDeprecationHandler())) {
email.priority(Email.Priority.resolve(parser.text()));
} else if (Field.SENT_DATE.match(currentFieldName, parser.getDeprecationHandler())) {
email.sentDate(new DateTime(parser.text(), DateTimeZone.UTC));
email.sentDate(ZonedDateTime.parse(parser.text())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd go with a strict_date_time formatter for clarity here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Core Core issues without another label >non-issue v7.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.