|
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().findAndAddModules().build(); |
44 | 45 | private final Function<Endpoint, String> buildProductPredicBasetUrl = this::buildProductPredictBaseUrl; |
45 | 46 | private final Function<String, String> buildWorkflowPredictBaseUrl = this::buildWorkflowPredictBaseUrl; |
46 | 47 | private final Function<String, String> buildWorkflowExecutionBaseUrl = this::buildWorkflowExecutionUrl; |
@@ -146,8 +147,6 @@ public <DocT extends Inference> AsyncPredictResponse<DocT> documentQueueGet( |
146 | 147 | String endpointUrl = documentUrlFromEndpoint.apply(endpoint).concat(jobId); |
147 | 148 | HttpGet get = new HttpGet(endpointUrl); |
148 | 149 |
|
149 | | - // required to register jackson date module format to deserialize |
150 | | - mapper.findAndRegisterModules(); |
151 | 150 | JavaType parametricType = mapper |
152 | 151 | .getTypeFactory() |
153 | 152 | .constructParametricType(AsyncPredictResponse.class, documentClass); |
@@ -198,8 +197,6 @@ public <DocT extends Inference> PredictResponse<DocT> predictPost( |
198 | 197 | String url = urlFromEndpoint.apply(endpoint); |
199 | 198 | HttpPost post = buildHttpPost(url, requestParameters); |
200 | 199 |
|
201 | | - // required to register jackson date module format to deserialize |
202 | | - mapper.findAndRegisterModules(); |
203 | 200 | JavaType parametricType = mapper |
204 | 201 | .getTypeFactory() |
205 | 202 | .constructParametricType(PredictResponse.class, documentClass); |
@@ -240,8 +237,6 @@ public <DocT extends Inference> AsyncPredictResponse<DocT> predictAsyncPost( |
240 | 237 | } |
241 | 238 | HttpPost post = buildHttpPost(url, requestParameters); |
242 | 239 |
|
243 | | - // required to register jackson date module format to deserialize |
244 | | - mapper.findAndRegisterModules(); |
245 | 240 | JavaType parametricType = mapper |
246 | 241 | .getTypeFactory() |
247 | 242 | .constructParametricType(AsyncPredictResponse.class, documentClass); |
@@ -277,8 +272,6 @@ public <DocT extends Inference> WorkflowResponse<DocT> executeWorkflowPost( |
277 | 272 | String url = workflowUrlFromId.apply(workflowId); |
278 | 273 | HttpPost post = buildHttpPost(url, requestParameters); |
279 | 274 |
|
280 | | - // required to register jackson date module format to deserialize |
281 | | - mapper.findAndRegisterModules(); |
282 | 275 | JavaType parametricType = mapper |
283 | 276 | .getTypeFactory() |
284 | 277 | .constructParametricType(WorkflowResponse.class, documentClass); |
|
0 commit comments