Skip to content

Commit 58b72d1

Browse files
committed
Merge branch '2.19'
2 parents e28900f + 013a62d commit 58b72d1

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed

src/test/java/tools/jackson/databind/deser/jdk/JDKNumberDeserTest.java

+92
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.io.StringReader;
44
import java.math.BigDecimal;
55
import java.math.BigInteger;
6+
import java.util.Arrays;
67
import java.util.List;
78
import java.util.Map;
89

@@ -109,6 +110,79 @@ static DecimalHolder4917 of(BigDecimal value) {
109110
}
110111
}
111112

113+
static class Point {
114+
private Double x;
115+
private Double y;
116+
117+
public Double getX() {
118+
return x;
119+
}
120+
121+
public void setX(Double x) {
122+
this.x = x;
123+
}
124+
125+
public Double getY() {
126+
return y;
127+
}
128+
129+
public void setY(Double y) {
130+
this.y = y;
131+
}
132+
}
133+
134+
@JsonTypeInfo(
135+
use = JsonTypeInfo.Id.NAME,
136+
include = JsonTypeInfo.As.EXISTING_PROPERTY,
137+
property = "type",
138+
visible = true)
139+
@JsonSubTypes(@JsonSubTypes.Type(value = CenterResult.class, name = "center"))
140+
static abstract class Result {
141+
private String type;
142+
143+
public String getType() {
144+
return type;
145+
}
146+
147+
public void setType(String type) {
148+
this.type = type;
149+
}
150+
}
151+
152+
static class CenterResult extends Result {
153+
private Point center;
154+
155+
private Double radius;
156+
157+
public Double getRadius() {
158+
return radius;
159+
}
160+
161+
public void setRadius(Double radius) {
162+
this.radius = radius;
163+
}
164+
165+
public Point getCenter() {
166+
return center;
167+
}
168+
169+
public void setCenter(Point center) {
170+
this.center = center;
171+
}
172+
}
173+
174+
static class Root {
175+
private Result[] results;
176+
177+
public Result[] getResults() {
178+
return results;
179+
}
180+
181+
public void setResults(Result[] results) {
182+
this.results = results;
183+
}
184+
}
185+
112186
/*
113187
/**********************************************************************
114188
/* Helper classes, serializers/deserializers/resolvers
@@ -472,4 +546,22 @@ public void bigDecimal4917V3() throws Exception
472546
assertEquals(new BigDecimal("100.00"), issue.decimal);
473547
assertEquals(50, issue.number);
474548
}
549+
550+
// https://github.com/FasterXML/jackson-core/issues/1397
551+
@Test
552+
public void issue1397() throws Exception {
553+
final String dataString = a2q("{ 'results': [ { " +
554+
"'radius': 179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, " +
555+
"'type': 'center', " +
556+
"'center': { " +
557+
"'x': -11.0, " +
558+
"'y': -2.0 } } ] }");
559+
560+
Root object = MAPPER.readValue(dataString, Root.class);
561+
562+
CenterResult result = (CenterResult) Arrays.stream(object.getResults()).findFirst().get();
563+
564+
assertEquals(-11.0d, result.getCenter().getX());
565+
assertEquals(-2.0d, result.getCenter().getY());
566+
}
475567
}

0 commit comments

Comments
 (0)