You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When generating BigDecimals on Java 11, JavaFixture populates the stringCache field with a random not-a-number string. This affects the .toString() method at the very least and, by proxy, affects JSON generated by ObjectMapper. The .intValue() also produces zero. On Java 17, the same field is populated by a correct string representation of the decimal.
Could it be that the reason it works on Java17 is the module system preventing access to internals and forcing JF to use a constructor?
Yes. That is a bug. We should not rely on reflection for a BigDecimal, similar to a BigInteger.
Therefore I propose we add it to the SpecialSpecimen classes and create one using a random value in a constructor.
When generating BigDecimals on Java 11, JavaFixture populates the stringCache field with a random not-a-number string. This affects the
.toString()
method at the very least and, by proxy, affects JSON generated by ObjectMapper. The.intValue()
also produces zero. On Java 17, the same field is populated by a correct string representation of the decimal.Could it be that the reason it works on Java17 is the module system preventing access to internals and forcing JF to use a constructor?
Test expected to pass
Json generated by Object mapper:
The cpc field is a BigDecimal. It's not even valid Json, which is more of a problem with ObjectMapper than JavaFixture tho.
Java 11 BigDecimal
Java 17 BigDecimal
The text was updated successfully, but these errors were encountered: