Skip to content

Commit

Permalink
Update release notes wrt #3133 fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Nov 28, 2023
1 parent 556a5bb commit 56356fe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
3 changes: 3 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Not yet released

#1172: `@JsonView` doesn't work with `@JsonCreator`
(reported by Dmitry B)
#3133: Map deserialization results in different numeric classes based on
json ordering (BigDecimal / Double) when used in combination with @JsonSubTypes
(reported by @mreiterer)
#4185: `@JsonIgnoreProperties` with `@JsonTypeInfo(include = JsonTypeInfo.As.EXTERNAL_PROPERTY)`
does not work
(reported by @jonasho)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
package com.fasterxml.jackson.databind.deser.jdk;
package com.fasterxml.jackson.databind.jsontype.jdk;

import static com.fasterxml.jackson.databind.BaseMapTest.jsonMapperBuilder;
import static com.fasterxml.jackson.databind.BaseTest.a2q;

import java.util.HashMap;
import java.util.Map;
Expand All @@ -10,9 +13,6 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import static com.fasterxml.jackson.databind.BaseMapTest.jsonMapperBuilder;
import static com.fasterxml.jackson.databind.BaseTest.a2q;

/**
* Unit test proving that below issue is fixed.
* <p>
Expand All @@ -27,11 +27,11 @@ public class BigDecimalForFloatDisabled3133Test
property = "type")

@JsonSubTypes({
@JsonSubTypes.Type(value = TestMapContainer.class, name = "MAP"),
@JsonSubTypes.Type(value = TestMapContainer3133.class, name = "MAP"),
})
interface TestJsonTypeInfoInterface { }
interface BaseType3133 { }

static class TestMapContainer implements TestJsonTypeInfoInterface {
static class TestMapContainer3133 implements BaseType3133 {

private Map<String, ? extends Object> map = new HashMap<>();

Expand All @@ -48,16 +48,18 @@ public void setMap(Map<String, ? extends Object> map) {
.disable(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)
.build();

// [databind#3133]
@Test
public void testDeserializeWithDifferentOrdering() throws Exception {
public void testDeserializeWithDifferentOrdering3133() throws Exception
{
// case 1 : type first
String ordering1 = a2q("{'type': 'MAP','map': { 'doubleValue': 0.1 }}");
TestMapContainer model1 = mapper.readValue(ordering1, TestMapContainer.class);
TestMapContainer3133 model1 = mapper.readValue(ordering1, TestMapContainer3133.class);
Assertions.assertTrue(model1.getMap().get("doubleValue") instanceof Double);

// case 2 : value first
String ordering2 = a2q("{'map': { 'doubleValue': 0.1 }, 'type': 'MAP'}");
TestMapContainer model2 = mapper.readValue(ordering2, TestMapContainer.class);
TestMapContainer3133 model2 = mapper.readValue(ordering2, TestMapContainer3133.class);
Assertions.assertTrue(model2.getMap().get("doubleValue") instanceof Double);
}
}

0 comments on commit 56356fe

Please sign in to comment.