-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Scripting: Switch watcher to use joda bwc time objects #35966
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
Conversation
This commit converts the watcher execution context to use the joda compat java time objects. It also again removes the joda methods from the painless whitelist.
This commit converts the watcher execution context to use the joda compat java time objects. It also again removes the joda methods from the painless whitelist.
This commit actually loads the joda whitelist, which was missed in
Pinging @elastic/es-core-features |
Pinging @elastic/es-core-infra |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me but I'm not a watcher expert.
assertThat(ObjectPath.eval("ctx", model), instanceOf(Map.class)); | ||
assertThat(ObjectPath.eval("ctx.id", model), is(wid.value())); | ||
assertThat(ObjectPath.eval("ctx.execution_time", model), is(executionTime)); | ||
// NOTE: we use toString() here because two ZonedDateTime are *not* equal, we need to check with isEqual | ||
// for date/time equality, but not hamcrest matcher exists |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but the hamcrest matcher doesn't exist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Judging from a quick peek into JodaCompatibleZonedDateTime
, it seems that its equals
methods is the culprit not the ZonedDateTime
? I think this snippet would fail
JodaCompatibleZonedDateTime d = new JodaCompatibleZonedDateTime(Instant.now(), ZoneOffset.UTC);
assertThat(d.equals(d), is(true));
not sure this is intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is semi-intentional, in that it just compares the underlying ZonedDateTime instances. To compare times, apparently isEqual is the thing to use...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left one question regarding the equals methods, I think this is also the reason for some of the test failures.
assertThat(ObjectPath.eval("ctx", model), instanceOf(Map.class)); | ||
assertThat(ObjectPath.eval("ctx.id", model), is(wid.value())); | ||
assertThat(ObjectPath.eval("ctx.execution_time", model), is(executionTime)); | ||
// NOTE: we use toString() here because two ZonedDateTime are *not* equal, we need to check with isEqual | ||
// for date/time equality, but not hamcrest matcher exists |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Judging from a quick peek into JodaCompatibleZonedDateTime
, it seems that its equals
methods is the culprit not the ZonedDateTime
? I think this snippet would fail
JodaCompatibleZonedDateTime d = new JodaCompatibleZonedDateTime(Instant.now(), ZoneOffset.UTC);
assertThat(d.equals(d), is(true));
not sure this is intentional?
this commit fixes the |
@elasticmachine test this please |
@elasticmachine test this please |
the remaining tests fail because of a different default formatting of the
on a per case base. But I think it makes sense to just put this into the |
This is an interesting problem. I had not thought about the toString() behavior. I had thought they were the same between joda/java. I guess in this case the upgrade to 7.0 will have to be hard break? Most of the time it is the same? |
|
I tried what I mentioned above and added a formatter to the |
Thanks @spinscale. I modified it as you suggested, but I do want to note the behavior would still change in 7.0 since the joda compatible object would disappear in favor of ZonedDateTime. It's probably fine, as anyone relying on whether nano seconds exist in a tostring inside a script are asking for trouble, but we should probably note this in migration docs when removing the compat object in master. |
mentioning in the logs sounds good to me! |
This commit converts the watcher execution context to use the joda compat java time objects. It also again removes the joda methods from the painless whitelist.
This commit converts the watcher execution context to use the joda compat java time objects. It also again removes the joda methods from the painless whitelist.
This commit converts the watcher execution context to use the joda
compat java time objects. It also again removes the joda methods from
the painless whitelist.