Skip to content

Commit 842a604

Browse files
CopilotJP-Ellis
andcommitted
fix: update Jackson imports for Spring Boot 4.x / Jackson 3.x compatibility
Co-authored-by: JP-Ellis <3196162+JP-Ellis@users.noreply.github.com>
1 parent 1ae1de6 commit 842a604

1 file changed

Lines changed: 6 additions & 19 deletions

File tree

src/main/java/com/example/products/ProductClient.java

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
import org.apache.http.client.fluent.Request;
44

5-
import com.fasterxml.jackson.core.type.TypeReference;
6-
import com.fasterxml.jackson.databind.JsonMappingException;
7-
import com.fasterxml.jackson.databind.ObjectMapper;
5+
import tools.jackson.core.type.TypeReference;
6+
import tools.jackson.databind.ObjectMapper;
87

98
import java.io.IOException;
109
import java.util.List;
@@ -22,29 +21,17 @@ public Product getProduct(String id) throws IOException {
2221
return (Product) Request.Get(this.url + "/product/" + id)
2322
.addHeader("Accept", "application/json")
2423
.execute().handleResponse(httpResponse -> {
25-
try {
26-
ObjectMapper mapper = new ObjectMapper();
27-
Product product = mapper.readValue(httpResponse.getEntity().getContent(), Product.class);
28-
29-
return product;
30-
} catch (JsonMappingException e) {
31-
throw new IOException(e);
32-
}
24+
ObjectMapper mapper = new ObjectMapper();
25+
return mapper.readValue(httpResponse.getEntity().getContent(), Product.class);
3326
});
3427
}
3528

3629
public List<Product> getProducts() throws IOException {
3730
return (List<Product>) Request.Get(this.url + "/products")
3831
.addHeader("Accept", "application/json")
3932
.execute().handleResponse(httpResponse -> {
40-
try {
41-
ObjectMapper mapper = new ObjectMapper();
42-
List<Product> products = mapper.readValue(httpResponse.getEntity().getContent(), new TypeReference<List<Product>>(){});
43-
44-
return products;
45-
} catch (JsonMappingException e) {
46-
throw new IOException(e);
47-
}
33+
ObjectMapper mapper = new ObjectMapper();
34+
return mapper.readValue(httpResponse.getEntity().getContent(), new TypeReference<List<Product>>(){});
4835
});
4936
}
5037
}

0 commit comments

Comments
 (0)