19
19
20
20
package co .elastic .clients .json ;
21
21
22
- import co .elastic .clients .json .JsonpMapper ;
23
22
import co .elastic .clients .json .jackson .JacksonJsonpMapper ;
24
23
import co .elastic .clients .json .jsonb .JsonbJsonpMapper ;
25
24
import com .fasterxml .jackson .annotation .JsonInclude ;
26
25
import com .fasterxml .jackson .core .type .TypeReference ;
27
26
import com .fasterxml .jackson .databind .ObjectMapper ;
28
27
import com .fasterxml .jackson .databind .PropertyNamingStrategies ;
28
+ import jakarta .json .JsonArray ;
29
+ import jakarta .json .JsonNumber ;
30
+ import jakarta .json .bind .spi .JsonbProvider ;
29
31
import jakarta .json .stream .JsonGenerator ;
30
32
import jakarta .json .stream .JsonParser ;
33
+ import org .eclipse .parsson .JsonProviderImpl ;
31
34
import org .junit .jupiter .api .Assertions ;
32
35
import org .junit .jupiter .api .Test ;
33
36
@@ -46,16 +49,18 @@ public class JsonpMapperTest extends Assertions {
46
49
47
50
@ Test
48
51
public void testJsonb () {
49
- JsonpMapper mapper = new JsonbJsonpMapper ();
52
+ JsonpMapper mapper = new JsonbJsonpMapper (new JsonProviderImpl (), JsonbProvider . provider () );
50
53
testSerialize (mapper , json );
51
54
testDeserialize (mapper , json );
55
+ testLargeNumber (mapper );
52
56
}
53
57
54
58
@ Test
55
59
public void testJackson () {
56
60
JacksonJsonpMapper mapper = new JacksonJsonpMapper ();
57
- testSerialize (new JacksonJsonpMapper (), json );
58
- testDeserialize (new JacksonJsonpMapper (), json );
61
+ testSerialize (mapper , json );
62
+ testDeserialize (mapper , json );
63
+ testLargeNumber (mapper );
59
64
}
60
65
61
66
@ Test
@@ -149,6 +154,20 @@ private void testDeserialize(JsonpMapper mapper, String json) {
149
154
assertNull (child .getChildren ());
150
155
}
151
156
157
+ private void testLargeNumber (JsonpMapper mapper ) {
158
+ String json = "[1e999999]" ;
159
+ JsonParser parser = mapper .jsonProvider ().createParser (new StringReader (json ));
160
+ parser .next ();
161
+
162
+ JsonArray array = parser .getValue ().asJsonArray ();
163
+
164
+ JsonNumber number = array .getJsonNumber (0 );
165
+
166
+ assertTrue (Double .isInfinite (number .doubleValue ()));
167
+
168
+ Assertions .assertThrows (Exception .class , number ::bigIntegerValue );
169
+ }
170
+
152
171
public static class SomeClass {
153
172
private List <SomeClass > children ;
154
173
private double doubleValue ;
0 commit comments