diff --git a/src/main/java/com/example/products/ProductClient.java b/src/main/java/com/example/products/ProductClient.java index 1db0106..f55c0c3 100644 --- a/src/main/java/com/example/products/ProductClient.java +++ b/src/main/java/com/example/products/ProductClient.java @@ -2,9 +2,8 @@ import org.apache.http.client.fluent.Request; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; +import tools.jackson.core.type.TypeReference; +import tools.jackson.databind.ObjectMapper; import java.io.IOException; import java.util.List; @@ -22,14 +21,8 @@ public Product getProduct(String id) throws IOException { return (Product) Request.Get(this.url + "/product/" + id) .addHeader("Accept", "application/json") .execute().handleResponse(httpResponse -> { - try { - ObjectMapper mapper = new ObjectMapper(); - Product product = mapper.readValue(httpResponse.getEntity().getContent(), Product.class); - - return product; - } catch (JsonMappingException e) { - throw new IOException(e); - } + ObjectMapper mapper = new ObjectMapper(); + return mapper.readValue(httpResponse.getEntity().getContent(), Product.class); }); } @@ -37,14 +30,8 @@ public List getProducts() throws IOException { return (List) Request.Get(this.url + "/products") .addHeader("Accept", "application/json") .execute().handleResponse(httpResponse -> { - try { - ObjectMapper mapper = new ObjectMapper(); - List products = mapper.readValue(httpResponse.getEntity().getContent(), new TypeReference>(){}); - - return products; - } catch (JsonMappingException e) { - throw new IOException(e); - } + ObjectMapper mapper = new ObjectMapper(); + return mapper.readValue(httpResponse.getEntity().getContent(), new TypeReference>(){}); }); } }