|
2 | 2 |
|
3 | 3 | import com.fasterxml.jackson.databind.*; |
4 | 4 | import com.fasterxml.jackson.databind.introspect.VisibilityChecker; |
| 5 | +import com.fasterxml.jackson.databind.json.JsonMapper; |
5 | 6 | import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; |
6 | 7 | import org.apache.commons.io.IOUtils; |
7 | 8 | import org.kohsuke.github.authorization.AuthorizationProvider; |
@@ -109,19 +110,21 @@ static class RetryRequestException extends IOException { |
109 | 110 | /** The Constant DEFAULT_MINIMUM_RETRY_TIMEOUT_MILLIS. */ |
110 | 111 | private static final int DEFAULT_MINIMUM_RETRY_MILLIS = DEFAULT_MAXIMUM_RETRY_MILLIS; |
111 | 112 | 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(); |
113 | 114 |
|
114 | 115 | private static final ThreadLocal<String> sendRequestTraceId = new ThreadLocal<>(); |
115 | 116 |
|
116 | 117 | /** The Constant GITHUB_URL. */ |
117 | 118 | static final String GITHUB_URL = "https://api.github.com"; |
118 | 119 |
|
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(); |
125 | 128 | } |
126 | 129 |
|
127 | 130 | @Nonnull |
|
0 commit comments