[ 
https://issues.apache.org/jira/browse/IGNITE-23648?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Vadim Pakhnushev reassigned IGNITE-23648:
-----------------------------------------

    Assignee: Vadim Pakhnushev

> Micronaut incorrectly deserializes Instant objects
> --------------------------------------------------
>
>                 Key: IGNITE-23648
>                 URL: https://issues.apache.org/jira/browse/IGNITE-23648
>             Project: Ignite
>          Issue Type: Bug
>          Components: rest
>            Reporter: Vadim Pakhnushev
>            Assignee: Vadim Pakhnushev
>            Priority: Major
>              Labels: ignite-3
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> Jackson library serializes {{Instant}} by default as a string of the form 
> {{millis.nanos}}.
> Micronaut uses Jackson to deserialize JSON payload, in particular, it uses 
> {{ObjectMapper.readTree}} method which reads JSON into a {{JsonNode}}. It 
> seems that when doing so, Jackson treats an {{Instant}} serialized by Jackson 
> using a {{double}} deserializer.
> This could lead to the loss of precision.
> The following test fails with the current version of Jackson:
> {code:java}
> @Test
> void instant() throws JsonProcessingException {
>     ObjectMapper mapper = new ObjectMapper();
>     mapper.registerModule(new JavaTimeModule());
>     Instant instant = Instant.ofEpochSecond(1730977056L, 232784600);
>     String s = mapper.writeValueAsString(instant);
>     JsonNode jsonNode = mapper.readTree(s);
>     Instant instant1 = mapper.treeToValue(jsonNode, Instant.class);
>     assertThat(instant1.getEpochSecond(), is(instant.getEpochSecond()));
>     assertThat(instant1.getNano(), is(instant.getNano())); // fails here, the 
> actual value is 232784500
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to