1919
2020package co .elastic .clients .json ;
2121
22- import co .elastic .clients .json .JsonpMapper ;
2322import co .elastic .clients .json .jackson .JacksonJsonpMapper ;
2423import co .elastic .clients .json .jsonb .JsonbJsonpMapper ;
2524import com .fasterxml .jackson .annotation .JsonInclude ;
2625import com .fasterxml .jackson .core .type .TypeReference ;
2726import com .fasterxml .jackson .databind .ObjectMapper ;
2827import com .fasterxml .jackson .databind .PropertyNamingStrategies ;
28+ import jakarta .json .JsonArray ;
29+ import jakarta .json .JsonNumber ;
30+ import jakarta .json .bind .spi .JsonbProvider ;
2931import jakarta .json .stream .JsonGenerator ;
3032import jakarta .json .stream .JsonParser ;
33+ import org .eclipse .parsson .JsonProviderImpl ;
3134import org .junit .jupiter .api .Assertions ;
3235import org .junit .jupiter .api .Test ;
3336
@@ -46,16 +49,18 @@ public class JsonpMapperTest extends Assertions {
4649
4750 @ Test
4851 public void testJsonb () {
49- JsonpMapper mapper = new JsonbJsonpMapper ();
52+ JsonpMapper mapper = new JsonbJsonpMapper (new JsonProviderImpl (), JsonbProvider . provider () );
5053 testSerialize (mapper , json );
5154 testDeserialize (mapper , json );
55+ testLargeNumber (mapper );
5256 }
5357
5458 @ Test
5559 public void testJackson () {
5660 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 );
5964 }
6065
6166 @ Test
@@ -149,6 +154,20 @@ private void testDeserialize(JsonpMapper mapper, String json) {
149154 assertNull (child .getChildren ());
150155 }
151156
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+
152171 public static class SomeClass {
153172 private List <SomeClass > children ;
154173 private double doubleValue ;
0 commit comments