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

[java] loss of precision with number fields #89

Open
postamar opened this issue Jul 3, 2024 · 0 comments
Open

[java] loss of precision with number fields #89

postamar opened this issue Jul 3, 2024 · 0 comments

Comments

@postamar
Copy link
Contributor

postamar commented Jul 3, 2024

We should set useBigDecimals = true in the jsonSchema2Pojo gradle config.

Presently, the protocol defines fields which are oddly of type number:

  • emitted_at in TRACE and CONTROL messages
  • record_count

The emitted_at field is always a millisecond epoch timestamp. In Java, the jackson library will always serialize double and float values using scientific notation, which can cause loss of precision in the least significant digits, yet these are precisely those which are interesting to the user here.

The record_count was deliberately picked to be a double though the reason isn't immediately obvious, a long should be quite sufficient.

In any case, the values are always integers and not terribly huge ones either, they should be perfectly safe to represent using BigDecimal.

This change is not backward-compatible, but perhaps that's not that big of a deal? I don't know.

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

No branches or pull requests

1 participant