11package com .maxmind .minfraud ;
22
33import com .fasterxml .jackson .core .type .TypeReference ;
4- import com .fasterxml .jackson .databind .DeserializationFeature ;
54import com .fasterxml .jackson .databind .InjectableValues ;
65import com .fasterxml .jackson .databind .InjectableValues .Std ;
7- import com .fasterxml .jackson .databind .MapperFeature ;
8- import com .fasterxml .jackson .databind .ObjectMapper ;
9- import com .fasterxml .jackson .databind .util .StdDateFormat ;
10- import com .fasterxml .jackson .datatype .jsr310 .JavaTimeModule ;
116import com .maxmind .minfraud .exception .*;
127import com .maxmind .minfraud .request .Transaction ;
138import com .maxmind .minfraud .request .TransactionReport ;
@@ -42,7 +37,6 @@ public final class WebServiceClient implements Closeable {
4237 private final List <String > locales ;
4338 private final Duration requestTimeout ;
4439
45- private final ObjectMapper mapper ;
4640 private final HttpClient httpClient ;
4741
4842 private WebServiceClient (WebServiceClient .Builder builder ) {
@@ -59,12 +53,6 @@ private WebServiceClient(WebServiceClient.Builder builder) {
5953 .encodeToString ((builder .accountId + ":" + builder .licenseKey )
6054 .getBytes (StandardCharsets .UTF_8 ));
6155
62- mapper = new ObjectMapper ();
63- mapper .disable (MapperFeature .CAN_OVERRIDE_ACCESS_MODIFIERS );
64- mapper .disable (DeserializationFeature .FAIL_ON_UNKNOWN_PROPERTIES );
65- mapper .registerModule (new JavaTimeModule ());
66- mapper .setDateFormat (new StdDateFormat ().withColonInTimeZone (true ));
67-
6856 requestTimeout = builder .requestTimeout ;
6957 HttpClient .Builder httpClientBuilder = HttpClient .newBuilder ()
7058 .proxy (builder .proxy );
@@ -409,7 +397,7 @@ private <T> T handleResponse(HttpResponse<InputStream> response, URI uri, Class<
409397 "locales" , locales );
410398
411399 try (InputStream stream = response .body ()) {
412- return mapper .readerFor (cls ).with (inject ).readValue (stream );
400+ return Mapper . get () .readerFor (cls ).with (inject ).readValue (stream );
413401 } catch (IOException e ) {
414402 throw new MinFraudException (
415403 "Received a 200 response but could not decode it as JSON" , e );
@@ -429,7 +417,7 @@ private void handle4xxStatus(HttpResponse<InputStream> response, URI uri)
429417
430418 Map <String , String > content ;
431419 try {
432- content = mapper .readValue (body ,
420+ content = Mapper . get () .readValue (body ,
433421 new TypeReference <HashMap <String , String >>() {
434422 });
435423 this .handleErrorWithJsonBody (content , body , status , uri );
@@ -516,7 +504,6 @@ public String toString() {
516504 ", port=" + port +
517505 ", useHttps=" + useHttps +
518506 ", locales=" + locales +
519- ", mapper=" + mapper +
520507 ", httpClient=" + httpClient +
521508 '}' ;
522509 }
0 commit comments