Skip to content

Commit 048efe0

Browse files
committed
Merge branch '2.19' into 2.20
2 parents 08e41ac + f2f5272 commit 048efe0

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
package com.fasterxml.jackson.datatype.jsr310.tofix;
1+
package com.fasterxml.jackson.datatype.jsr310.deser;
22

33
import java.time.Instant;
44

55
import org.junit.jupiter.api.Test;
66

77
import com.fasterxml.jackson.databind.JsonNode;
88
import com.fasterxml.jackson.databind.ObjectMapper;
9+
import com.fasterxml.jackson.databind.cfg.JsonNodeFeature;
910
import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase;
10-
import com.fasterxml.jackson.datatype.jsr310.testutil.failure.JacksonTestFailureExpected;
1111

1212
import static org.junit.jupiter.api.Assertions.*;
1313

1414
// [modules-java8#307]: Loss of precision via JsonNode for BigDecimal-valued
1515
// things (like Instant)
16-
public class InstanceViaBigDecimal307Test extends ModuleTestBase
16+
// Solved via `JsonNodeFeature.USE_BIG_DECIMAL_FOR_FLOATS` added in Jackson 2.19
17+
public class InstantViaBigDecimal307Test extends ModuleTestBase
1718
{
1819
static class Wrapper307 {
1920
public Instant value;
@@ -24,7 +25,10 @@ protected Wrapper307() { }
2425

2526
private final Instant ISSUED_AT = Instant.ofEpochSecond(1234567890).plusNanos(123456789);
2627

27-
private ObjectMapper MAPPER = newMapper();
28+
private ObjectMapper MAPPER = mapperBuilder()
29+
// added in 2.19
30+
.enable(JsonNodeFeature.USE_BIG_DECIMAL_FOR_FLOATS)
31+
.build();
2832

2933
@Test
3034
public void instantViaReadValue() throws Exception {
@@ -33,7 +37,6 @@ public void instantViaReadValue() throws Exception {
3337
assertEquals(ISSUED_AT, deserialized.value);
3438
}
3539

36-
@JacksonTestFailureExpected
3740
@Test
3841
public void instantViaReadTree() throws Exception {
3942
String serialized = MAPPER.writeValueAsString(new Wrapper307(ISSUED_AT));

release-notes/VERSION-2.x

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ No changes since 2.19.0
2222

2323
2.19.0 (24-Apr-2025)
2424

25+
#307: Instant precision should be retained in ObjectMapper#readTree (add
26+
`JsonNodeFeature.USE_BIG_DECIMAL_FOR_FLOATS` to force use of `BigDecimal`
27+
for `JsonNode` reads)
28+
(reported by @jzheaux)
2529
#336: Optimize `InstantDeserializer` `addInColonToOffsetIfMissing()`
2630
(contributed by David S)
2731
#337: Negative `Duration` does not round-trip properly with

0 commit comments

Comments
 (0)