diff --git a/pom.xml b/pom.xml
index 4f50e2d8ac..e1fbffe519 100644
--- a/pom.xml
+++ b/pom.xml
@@ -89,7 +89,7 @@
com.fasterxml.jackson
jackson-bom
- 2.20.0
+ 2.21.0
pom
import
diff --git a/src/main/java/org/kohsuke/github/GHEventInfo.java b/src/main/java/org/kohsuke/github/GHEventInfo.java
index b9adccf2e6..7172583c51 100644
--- a/src/main/java/org/kohsuke/github/GHEventInfo.java
+++ b/src/main/java/org/kohsuke/github/GHEventInfo.java
@@ -174,7 +174,7 @@ public GHOrganization getOrganization() throws IOException {
* if payload cannot be parsed
*/
public T getPayload(Class type) throws IOException {
- T v = GitHubClient.getMappingObjectReader(root()).readValue(payload.traverse(), type);
+ T v = GitHubClient.getMappingObjectReader(root()).forType(type).readValue(payload);
v.lateBind();
return v;
}
diff --git a/src/main/java/org/kohsuke/github/GitHubClient.java b/src/main/java/org/kohsuke/github/GitHubClient.java
index 70eec892ec..7963de57e2 100644
--- a/src/main/java/org/kohsuke/github/GitHubClient.java
+++ b/src/main/java/org/kohsuke/github/GitHubClient.java
@@ -2,6 +2,7 @@
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.introspect.VisibilityChecker;
+import com.fasterxml.jackson.databind.json.JsonMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import org.apache.commons.io.IOUtils;
import org.kohsuke.github.authorization.AuthorizationProvider;
@@ -109,21 +110,19 @@ static class RetryRequestException extends IOException {
/** The Constant DEFAULT_MINIMUM_RETRY_TIMEOUT_MILLIS. */
private static final int DEFAULT_MINIMUM_RETRY_MILLIS = DEFAULT_MAXIMUM_RETRY_MILLIS;
private static final Logger LOGGER = Logger.getLogger(GitHubClient.class.getName());
- private static final ObjectMapper MAPPER = new ObjectMapper();
+ private static final ObjectMapper MAPPER = JsonMapper.builder()
+ .addModule(new JavaTimeModule())
+ .visibility(new VisibilityChecker.Std(NONE, NONE, NONE, NONE, ANY))
+ .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
+ .enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS)
+ .propertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE)
+ .build();
private static final ThreadLocal sendRequestTraceId = new ThreadLocal<>();
/** The Constant GITHUB_URL. */
static final String GITHUB_URL = "https://api.github.com";
- static {
- MAPPER.registerModule(new JavaTimeModule());
- MAPPER.setVisibility(new VisibilityChecker.Std(NONE, NONE, NONE, NONE, ANY));
- MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- MAPPER.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS, true);
- MAPPER.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE);
- }
-
@Nonnull
private static GitHubResponse createResponse(@Nonnull GitHubConnectorResponse connectorResponse,
@CheckForNull BodyHandler handler) throws IOException {
diff --git a/src/test/java/org/kohsuke/github/AotIntegrationTest.java b/src/test/java/org/kohsuke/github/AotIntegrationTest.java
index a8b458f792..f0215bb0e7 100644
--- a/src/test/java/org/kohsuke/github/AotIntegrationTest.java
+++ b/src/test/java/org/kohsuke/github/AotIntegrationTest.java
@@ -1,7 +1,7 @@
package org.kohsuke.github;
import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.json.JsonMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import org.junit.Test;
import org.springframework.boot.test.context.SpringBootTest;
@@ -80,7 +80,9 @@ public void testIfAllRequiredClassesAreRegisteredForAot() throws IOException {
private Stream readAotConfigToStreamOfClassNames(String reflectionConfig) throws IOException {
byte[] reflectionConfigFileAsBytes = Files.readAllBytes(Path.of(reflectionConfig));
- ArrayNode reflectConfigJsonArray = (ArrayNode) new ObjectMapper().readTree(reflectionConfigFileAsBytes);
+ ArrayNode reflectConfigJsonArray = (ArrayNode) JsonMapper.builder()
+ .build()
+ .readTree(reflectionConfigFileAsBytes);
return StreamSupport
.stream(Spliterators.spliteratorUnknownSize(reflectConfigJsonArray.iterator(), Spliterator.ORDERED),
false)
diff --git a/src/test/java/org/kohsuke/github/internal/graphql/response/GHGraphQLResponseMockTest.java b/src/test/java/org/kohsuke/github/internal/graphql/response/GHGraphQLResponseMockTest.java
index a98870c6ec..965e8fc7c6 100644
--- a/src/test/java/org/kohsuke/github/internal/graphql/response/GHGraphQLResponseMockTest.java
+++ b/src/test/java/org/kohsuke/github/internal/graphql/response/GHGraphQLResponseMockTest.java
@@ -3,8 +3,8 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JavaType;
-import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;
+import com.fasterxml.jackson.databind.json.JsonMapper;
import org.junit.jupiter.api.Test;
import java.util.List;
@@ -20,10 +20,9 @@
class GHGraphQLResponseMockTest {
private GHGraphQLResponse