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

tests: support more-precise clocks in Java 11 #10381

Merged
merged 1 commit into from
Feb 5, 2019

Conversation

yaauie
Copy link
Member

@yaauie yaauie commented Feb 5, 2019

targets: master, 6.x (same targets as Java Plugin API that introduced these tests).

In Java 8, java.lang.Instant#now() used the system clock, which only had millisecond-level precision, but starting with Java 9, the system clock is much more precise.

Since we create our org.logstash.Timestamp with long epoch_milliseconds, it cannot represent a time more precisely than milliseconds.

Ensure that the output of Timestamp#usec is rounded before comparing it with milliseconds, in order to avoid asserting greater precision than we can create.

@yaauie
Copy link
Member Author

yaauie commented Feb 5, 2019

Jenkins test this please

@jsvd jsvd requested a review from danhermann February 5, 2019 11:23
Copy link
Contributor

@danhermann danhermann left a comment

Choose a reason for hiding this comment

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

Hmm, my original test was not that great in that it supplied millisecond precision for the seed value and then tested the microsecond component which would always be zero.

Edit: NVM, everything looks good. Math is hard. Or rather, the usec method on Timestamp follows Ruby conventions rather than the Java convention that getNanos does for Instant. Another consequence of mixing ecosystems.

@elasticsearch-bot
Copy link

Ry Biesemeyer merged this into the following branches!

Branch Commits
6.x c95eff6

elasticsearch-bot pushed a commit that referenced this pull request Feb 5, 2019
@yaauie yaauie merged commit 9e886a9 into elastic:master Feb 5, 2019
@yaauie yaauie deleted the java-11-support-clock-precision branch February 5, 2019 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants