11package com .maxmind .geoip2 ;
22
3- import com .fasterxml .jackson .core .type .TypeReference ;
4- import com .fasterxml .jackson .databind .DeserializationFeature ;
5- import com .fasterxml .jackson .databind .InjectableValues ;
6- import com .fasterxml .jackson .databind .MapperFeature ;
7- import com .fasterxml .jackson .databind .ObjectMapper ;
8- import com .fasterxml .jackson .databind .SerializationFeature ;
9- import com .fasterxml .jackson .databind .json .JsonMapper ;
10- import com .fasterxml .jackson .datatype .jsr310 .JavaTimeModule ;
3+ import tools .jackson .core .JacksonException ;
4+ import tools .jackson .core .type .TypeReference ;
5+ import tools .jackson .databind .DeserializationFeature ;
6+ import tools .jackson .databind .InjectableValues ;
7+ import tools .jackson .databind .ObjectMapper ;
8+ import tools .jackson .databind .json .JsonMapper ;
119import com .maxmind .geoip2 .exception .AddressNotFoundException ;
1210import com .maxmind .geoip2 .exception .AuthenticationException ;
1311import com .maxmind .geoip2 .exception .GeoIp2Exception ;
2119import java .io .IOException ;
2220import java .io .InputStream ;
2321import java .net .InetAddress ;
24- import java .net .InetSocketAddress ;
2522import java .net .ProxySelector ;
2623import java .net .URI ;
2724import java .net .URISyntaxException ;
@@ -133,10 +130,8 @@ private WebServiceClient(Builder builder) {
133130 (builder .accountId + ":" + builder .licenseKey ).getBytes (StandardCharsets .UTF_8 ));
134131
135132 mapper = JsonMapper .builder ()
136- .disable (MapperFeature .CAN_OVERRIDE_ACCESS_MODIFIERS )
137133 .disable (DeserializationFeature .FAIL_ON_UNKNOWN_PROPERTIES )
138- .disable (SerializationFeature .WRITE_DATES_AS_TIMESTAMPS )
139- .addModule (new JavaTimeModule ())
134+ .disable (DeserializationFeature .FAIL_ON_NULL_FOR_PRIMITIVES )
140135 .build ();
141136
142137 requestTimeout = builder .requestTimeout ;
@@ -405,7 +400,7 @@ private <T> T handleResponse(HttpResponse<InputStream> response, Class<T> cls)
405400
406401 try {
407402 return mapper .readerFor (cls ).with (inject ).readValue (response .body ());
408- } catch (IOException e ) {
403+ } catch (JacksonException e ) {
409404 throw new GeoIp2Exception (
410405 "Received a 200 response but could not decode it as JSON" , e );
411406 }
@@ -429,7 +424,7 @@ private void handle4xxStatus(HttpResponse<InputStream> response)
429424 handleErrorWithJsonBody (content , body , status , uri );
430425 } catch (HttpException e ) {
431426 throw e ;
432- } catch (IOException e ) {
427+ } catch (JacksonException e ) {
433428 throw new HttpException ("Received a " + status + " error for "
434429 + uri + " but it did not include the expected JSON body: "
435430 + body , status , uri );
0 commit comments