|
3 | 3 | import com.fasterxml.jackson.core.JsonProcessingException; |
4 | 4 | import com.fasterxml.jackson.databind.JavaType; |
5 | 5 | import com.fasterxml.jackson.databind.ObjectMapper; |
| 6 | +import com.fasterxml.jackson.databind.json.JsonMapper; |
6 | 7 | import com.mindee.MindeeException; |
7 | 8 | import com.mindee.MindeeSettings; |
8 | 9 | import com.mindee.parsing.common.ApiResponse; |
|
40 | 41 | */ |
41 | 42 | public final class MindeeHttpApi extends MindeeApi { |
42 | 43 |
|
43 | | - private static final ObjectMapper mapper = new ObjectMapper(); |
| 44 | + private static final ObjectMapper mapper = JsonMapper.builder() |
| 45 | + .findAndAddModules() |
| 46 | + .build(); |
44 | 47 | private final Function<Endpoint, String> buildProductPredicBasetUrl = this::buildProductPredictBaseUrl; |
45 | 48 | private final Function<String, String> buildWorkflowPredictBaseUrl = this::buildWorkflowPredictBaseUrl; |
46 | 49 | private final Function<String, String> buildWorkflowExecutionBaseUrl = this::buildWorkflowExecutionUrl; |
@@ -146,8 +149,6 @@ public <DocT extends Inference> AsyncPredictResponse<DocT> documentQueueGet( |
146 | 149 | String endpointUrl = documentUrlFromEndpoint.apply(endpoint).concat(jobId); |
147 | 150 | HttpGet get = new HttpGet(endpointUrl); |
148 | 151 |
|
149 | | - // required to register jackson date module format to deserialize |
150 | | - mapper.findAndRegisterModules(); |
151 | 152 | JavaType parametricType = mapper |
152 | 153 | .getTypeFactory() |
153 | 154 | .constructParametricType(AsyncPredictResponse.class, documentClass); |
@@ -198,8 +199,6 @@ public <DocT extends Inference> PredictResponse<DocT> predictPost( |
198 | 199 | String url = urlFromEndpoint.apply(endpoint); |
199 | 200 | HttpPost post = buildHttpPost(url, requestParameters); |
200 | 201 |
|
201 | | - // required to register jackson date module format to deserialize |
202 | | - mapper.findAndRegisterModules(); |
203 | 202 | JavaType parametricType = mapper |
204 | 203 | .getTypeFactory() |
205 | 204 | .constructParametricType(PredictResponse.class, documentClass); |
@@ -240,8 +239,6 @@ public <DocT extends Inference> AsyncPredictResponse<DocT> predictAsyncPost( |
240 | 239 | } |
241 | 240 | HttpPost post = buildHttpPost(url, requestParameters); |
242 | 241 |
|
243 | | - // required to register jackson date module format to deserialize |
244 | | - mapper.findAndRegisterModules(); |
245 | 242 | JavaType parametricType = mapper |
246 | 243 | .getTypeFactory() |
247 | 244 | .constructParametricType(AsyncPredictResponse.class, documentClass); |
@@ -277,8 +274,6 @@ public <DocT extends Inference> WorkflowResponse<DocT> executeWorkflowPost( |
277 | 274 | String url = workflowUrlFromId.apply(workflowId); |
278 | 275 | HttpPost post = buildHttpPost(url, requestParameters); |
279 | 276 |
|
280 | | - // required to register jackson date module format to deserialize |
281 | | - mapper.findAndRegisterModules(); |
282 | 277 | JavaType parametricType = mapper |
283 | 278 | .getTypeFactory() |
284 | 279 | .constructParametricType(WorkflowResponse.class, documentClass); |
|
0 commit comments