Skip to content

Commit b85ff94

Browse files
committed
Support Jackson 2.20+ removal of PropertyNamingStrategy
1 parent 970fd47 commit b85ff94

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
<dependency>
9090
<groupId>com.fasterxml.jackson</groupId>
9191
<artifactId>jackson-bom</artifactId>
92-
<version>2.19.1</version>
92+
<version>2.20.0</version>
9393
<type>pom</type>
9494
<scope>import</scope>
9595
</dependency>

src/main/java/org/kohsuke/github/GitHubClient.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.fasterxml.jackson.databind.*;
44
import com.fasterxml.jackson.databind.introspect.VisibilityChecker;
5+
import com.fasterxml.jackson.databind.json.JsonMapper;
56
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
67
import org.apache.commons.io.IOUtils;
78
import org.kohsuke.github.authorization.AuthorizationProvider;
@@ -109,19 +110,21 @@ static class RetryRequestException extends IOException {
109110
/** The Constant DEFAULT_MINIMUM_RETRY_TIMEOUT_MILLIS. */
110111
private static final int DEFAULT_MINIMUM_RETRY_MILLIS = DEFAULT_MAXIMUM_RETRY_MILLIS;
111112
private static final Logger LOGGER = Logger.getLogger(GitHubClient.class.getName());
112-
private static final ObjectMapper MAPPER = new ObjectMapper();
113+
private static final ObjectMapper MAPPER = buildObjectMapper();
113114

114115
private static final ThreadLocal<String> sendRequestTraceId = new ThreadLocal<>();
115116

116117
/** The Constant GITHUB_URL. */
117118
static final String GITHUB_URL = "https://api.github.com";
118119

119-
static {
120-
MAPPER.registerModule(new JavaTimeModule());
121-
MAPPER.setVisibility(new VisibilityChecker.Std(NONE, NONE, NONE, NONE, ANY));
122-
MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
123-
MAPPER.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS, true);
124-
MAPPER.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
120+
private static ObjectMapper buildObjectMapper() {
121+
return JsonMapper.builder()
122+
.addModule(new JavaTimeModule())
123+
.visibility(new VisibilityChecker.Std(NONE, NONE, NONE, NONE, ANY))
124+
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
125+
.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS, true)
126+
.propertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE)
127+
.build();
125128
}
126129

127130
@Nonnull

0 commit comments

Comments
 (0)