Fix java rest client's ApiClient constructors to make sure objectMapper parameter is used in the client (#19667) (#19795)

This commit is contained in:
CaptainAye 2024-10-08 03:47:16 +02:00 committed by GitHub
parent 7cf84e2daf
commit a82475ed4e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 56 additions and 77 deletions

View File

@ -87,29 +87,26 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
public ApiClient() { public ApiClient() {
this.dateFormat = createDefaultDateFormat(); this(null);
this.objectMapper = createDefaultObjectMapper(this.dateFormat);
this.restClient = buildRestClient(this.objectMapper);
this.init();
} }
public ApiClient(RestClient restClient) { public ApiClient(RestClient restClient) {
this(Optional.ofNullable(restClient).orElseGet(ApiClient::buildRestClient), createDefaultDateFormat()); this(restClient, createDefaultDateFormat());
} }
public ApiClient(ObjectMapper mapper, DateFormat format) { public ApiClient(ObjectMapper mapper, DateFormat format) {
this(buildRestClient(mapper.copy()), format); this(null, mapper, format);
} }
public ApiClient(RestClient restClient, ObjectMapper mapper, DateFormat format) { public ApiClient(RestClient restClient, ObjectMapper mapper, DateFormat format) {
this(Optional.ofNullable(restClient).orElseGet(() -> buildRestClient(mapper.copy())), format); this.objectMapper = mapper.copy();
this.restClient = Optional.ofNullable(restClient).orElseGet(() -> buildRestClient(this.objectMapper));
this.dateFormat = format;
this.init();
} }
private ApiClient(RestClient restClient, DateFormat format) { private ApiClient(RestClient restClient, DateFormat format) {
this.restClient = restClient; this(restClient, createDefaultObjectMapper(format), format);
this.dateFormat = format;
this.objectMapper = createDefaultObjectMapper(format);
this.init();
} }
public static DateFormat createDefaultDateFormat() { public static DateFormat createDefaultDateFormat() {

View File

@ -84,29 +84,26 @@ public class ApiClient extends JavaTimeFormatter {
public ApiClient() { public ApiClient() {
this.dateFormat = createDefaultDateFormat(); this(null);
this.objectMapper = createDefaultObjectMapper(this.dateFormat);
this.restClient = buildRestClient(this.objectMapper);
this.init();
} }
public ApiClient(RestClient restClient) { public ApiClient(RestClient restClient) {
this(Optional.ofNullable(restClient).orElseGet(ApiClient::buildRestClient), createDefaultDateFormat()); this(restClient, createDefaultDateFormat());
} }
public ApiClient(ObjectMapper mapper, DateFormat format) { public ApiClient(ObjectMapper mapper, DateFormat format) {
this(buildRestClient(mapper.copy()), format); this(null, mapper, format);
} }
public ApiClient(RestClient restClient, ObjectMapper mapper, DateFormat format) { public ApiClient(RestClient restClient, ObjectMapper mapper, DateFormat format) {
this(Optional.ofNullable(restClient).orElseGet(() -> buildRestClient(mapper.copy())), format); this.objectMapper = mapper.copy();
this.restClient = Optional.ofNullable(restClient).orElseGet(() -> buildRestClient(this.objectMapper));
this.dateFormat = format;
this.init();
} }
private ApiClient(RestClient restClient, DateFormat format) { private ApiClient(RestClient restClient, DateFormat format) {
this.restClient = restClient; this(restClient, createDefaultObjectMapper(format), format);
this.dateFormat = format;
this.objectMapper = createDefaultObjectMapper(format);
this.init();
} }
public static DateFormat createDefaultDateFormat() { public static DateFormat createDefaultDateFormat() {

View File

@ -84,29 +84,26 @@ public class ApiClient extends JavaTimeFormatter {
public ApiClient() { public ApiClient() {
this.dateFormat = createDefaultDateFormat(); this(null);
this.objectMapper = createDefaultObjectMapper(this.dateFormat);
this.restClient = buildRestClient(this.objectMapper);
this.init();
} }
public ApiClient(RestClient restClient) { public ApiClient(RestClient restClient) {
this(Optional.ofNullable(restClient).orElseGet(ApiClient::buildRestClient), createDefaultDateFormat()); this(restClient, createDefaultDateFormat());
} }
public ApiClient(ObjectMapper mapper, DateFormat format) { public ApiClient(ObjectMapper mapper, DateFormat format) {
this(buildRestClient(mapper.copy()), format); this(null, mapper, format);
} }
public ApiClient(RestClient restClient, ObjectMapper mapper, DateFormat format) { public ApiClient(RestClient restClient, ObjectMapper mapper, DateFormat format) {
this(Optional.ofNullable(restClient).orElseGet(() -> buildRestClient(mapper.copy())), format); this.objectMapper = mapper.copy();
this.restClient = Optional.ofNullable(restClient).orElseGet(() -> buildRestClient(this.objectMapper));
this.dateFormat = format;
this.init();
} }
private ApiClient(RestClient restClient, DateFormat format) { private ApiClient(RestClient restClient, DateFormat format) {
this.restClient = restClient; this(restClient, createDefaultObjectMapper(format), format);
this.dateFormat = format;
this.objectMapper = createDefaultObjectMapper(format);
this.init();
} }
public static DateFormat createDefaultDateFormat() { public static DateFormat createDefaultDateFormat() {

View File

@ -84,29 +84,26 @@ public class ApiClient extends JavaTimeFormatter {
public ApiClient() { public ApiClient() {
this.dateFormat = createDefaultDateFormat(); this(null);
this.objectMapper = createDefaultObjectMapper(this.dateFormat);
this.restClient = buildRestClient(this.objectMapper);
this.init();
} }
public ApiClient(RestClient restClient) { public ApiClient(RestClient restClient) {
this(Optional.ofNullable(restClient).orElseGet(ApiClient::buildRestClient), createDefaultDateFormat()); this(restClient, createDefaultDateFormat());
} }
public ApiClient(ObjectMapper mapper, DateFormat format) { public ApiClient(ObjectMapper mapper, DateFormat format) {
this(buildRestClient(mapper.copy()), format); this(null, mapper, format);
} }
public ApiClient(RestClient restClient, ObjectMapper mapper, DateFormat format) { public ApiClient(RestClient restClient, ObjectMapper mapper, DateFormat format) {
this(Optional.ofNullable(restClient).orElseGet(() -> buildRestClient(mapper.copy())), format); this.objectMapper = mapper.copy();
this.restClient = Optional.ofNullable(restClient).orElseGet(() -> buildRestClient(this.objectMapper));
this.dateFormat = format;
this.init();
} }
private ApiClient(RestClient restClient, DateFormat format) { private ApiClient(RestClient restClient, DateFormat format) {
this.restClient = restClient; this(restClient, createDefaultObjectMapper(format), format);
this.dateFormat = format;
this.objectMapper = createDefaultObjectMapper(format);
this.init();
} }
public static DateFormat createDefaultDateFormat() { public static DateFormat createDefaultDateFormat() {

View File

@ -85,29 +85,26 @@ public class ApiClient extends JavaTimeFormatter {
public ApiClient() { public ApiClient() {
this.dateFormat = createDefaultDateFormat(); this(null);
this.objectMapper = createDefaultObjectMapper(this.dateFormat);
this.restClient = buildRestClient(this.objectMapper);
this.init();
} }
public ApiClient(RestClient restClient) { public ApiClient(RestClient restClient) {
this(Optional.ofNullable(restClient).orElseGet(ApiClient::buildRestClient), createDefaultDateFormat()); this(restClient, createDefaultDateFormat());
} }
public ApiClient(ObjectMapper mapper, DateFormat format) { public ApiClient(ObjectMapper mapper, DateFormat format) {
this(buildRestClient(mapper.copy()), format); this(null, mapper, format);
} }
public ApiClient(RestClient restClient, ObjectMapper mapper, DateFormat format) { public ApiClient(RestClient restClient, ObjectMapper mapper, DateFormat format) {
this(Optional.ofNullable(restClient).orElseGet(() -> buildRestClient(mapper.copy())), format); this.objectMapper = mapper.copy();
this.restClient = Optional.ofNullable(restClient).orElseGet(() -> buildRestClient(this.objectMapper));
this.dateFormat = format;
this.init();
} }
private ApiClient(RestClient restClient, DateFormat format) { private ApiClient(RestClient restClient, DateFormat format) {
this.restClient = restClient; this(restClient, createDefaultObjectMapper(format), format);
this.dateFormat = format;
this.objectMapper = createDefaultObjectMapper(format);
this.init();
} }
public static DateFormat createDefaultDateFormat() { public static DateFormat createDefaultDateFormat() {

View File

@ -85,29 +85,26 @@ public class ApiClient extends JavaTimeFormatter {
public ApiClient() { public ApiClient() {
this.dateFormat = createDefaultDateFormat(); this(null);
this.objectMapper = createDefaultObjectMapper(this.dateFormat);
this.restClient = buildRestClient(this.objectMapper);
this.init();
} }
public ApiClient(RestClient restClient) { public ApiClient(RestClient restClient) {
this(Optional.ofNullable(restClient).orElseGet(ApiClient::buildRestClient), createDefaultDateFormat()); this(restClient, createDefaultDateFormat());
} }
public ApiClient(ObjectMapper mapper, DateFormat format) { public ApiClient(ObjectMapper mapper, DateFormat format) {
this(buildRestClient(mapper.copy()), format); this(null, mapper, format);
} }
public ApiClient(RestClient restClient, ObjectMapper mapper, DateFormat format) { public ApiClient(RestClient restClient, ObjectMapper mapper, DateFormat format) {
this(Optional.ofNullable(restClient).orElseGet(() -> buildRestClient(mapper.copy())), format); this.objectMapper = mapper.copy();
this.restClient = Optional.ofNullable(restClient).orElseGet(() -> buildRestClient(this.objectMapper));
this.dateFormat = format;
this.init();
} }
private ApiClient(RestClient restClient, DateFormat format) { private ApiClient(RestClient restClient, DateFormat format) {
this.restClient = restClient; this(restClient, createDefaultObjectMapper(format), format);
this.dateFormat = format;
this.objectMapper = createDefaultObjectMapper(format);
this.init();
} }
public static DateFormat createDefaultDateFormat() { public static DateFormat createDefaultDateFormat() {

View File

@ -85,29 +85,26 @@ public class ApiClient extends JavaTimeFormatter {
public ApiClient() { public ApiClient() {
this.dateFormat = createDefaultDateFormat(); this(null);
this.objectMapper = createDefaultObjectMapper(this.dateFormat);
this.restClient = buildRestClient(this.objectMapper);
this.init();
} }
public ApiClient(RestClient restClient) { public ApiClient(RestClient restClient) {
this(Optional.ofNullable(restClient).orElseGet(ApiClient::buildRestClient), createDefaultDateFormat()); this(restClient, createDefaultDateFormat());
} }
public ApiClient(ObjectMapper mapper, DateFormat format) { public ApiClient(ObjectMapper mapper, DateFormat format) {
this(buildRestClient(mapper.copy()), format); this(null, mapper, format);
} }
public ApiClient(RestClient restClient, ObjectMapper mapper, DateFormat format) { public ApiClient(RestClient restClient, ObjectMapper mapper, DateFormat format) {
this(Optional.ofNullable(restClient).orElseGet(() -> buildRestClient(mapper.copy())), format); this.objectMapper = mapper.copy();
this.restClient = Optional.ofNullable(restClient).orElseGet(() -> buildRestClient(this.objectMapper));
this.dateFormat = format;
this.init();
} }
private ApiClient(RestClient restClient, DateFormat format) { private ApiClient(RestClient restClient, DateFormat format) {
this.restClient = restClient; this(restClient, createDefaultObjectMapper(format), format);
this.dateFormat = format;
this.objectMapper = createDefaultObjectMapper(format);
this.init();
} }
public static DateFormat createDefaultDateFormat() { public static DateFormat createDefaultDateFormat() {