Skip to content

Commit

Permalink
Fix java rest client's ApiClient constructors to make sure objectMapp…
Browse files Browse the repository at this point in the history
…er parameter is used in the client (#19667) (#19795)
  • Loading branch information
CaptainAye authored Oct 8, 2024
1 parent 7cf84e2 commit a82475e
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,29 +87,26 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {


public ApiClient() {
this.dateFormat = createDefaultDateFormat();
this.objectMapper = createDefaultObjectMapper(this.dateFormat);
this.restClient = buildRestClient(this.objectMapper);
this.init();
this(null);
}

public ApiClient(RestClient restClient) {
this(Optional.ofNullable(restClient).orElseGet(ApiClient::buildRestClient), createDefaultDateFormat());
this(restClient, createDefaultDateFormat());
}

public ApiClient(ObjectMapper mapper, DateFormat format) {
this(buildRestClient(mapper.copy()), format);
this(null, mapper, 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) {
this.restClient = restClient;
this.dateFormat = format;
this.objectMapper = createDefaultObjectMapper(format);
this.init();
this(restClient, createDefaultObjectMapper(format), format);
}

public static DateFormat createDefaultDateFormat() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,29 +84,26 @@ private String collectionToString(Collection<?> collection) {


public ApiClient() {
this.dateFormat = createDefaultDateFormat();
this.objectMapper = createDefaultObjectMapper(this.dateFormat);
this.restClient = buildRestClient(this.objectMapper);
this.init();
this(null);
}

public ApiClient(RestClient restClient) {
this(Optional.ofNullable(restClient).orElseGet(ApiClient::buildRestClient), createDefaultDateFormat());
this(restClient, createDefaultDateFormat());
}

public ApiClient(ObjectMapper mapper, DateFormat format) {
this(buildRestClient(mapper.copy()), format);
this(null, mapper, 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) {
this.restClient = restClient;
this.dateFormat = format;
this.objectMapper = createDefaultObjectMapper(format);
this.init();
this(restClient, createDefaultObjectMapper(format), format);
}

public static DateFormat createDefaultDateFormat() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,29 +84,26 @@ private String collectionToString(Collection<?> collection) {


public ApiClient() {
this.dateFormat = createDefaultDateFormat();
this.objectMapper = createDefaultObjectMapper(this.dateFormat);
this.restClient = buildRestClient(this.objectMapper);
this.init();
this(null);
}

public ApiClient(RestClient restClient) {
this(Optional.ofNullable(restClient).orElseGet(ApiClient::buildRestClient), createDefaultDateFormat());
this(restClient, createDefaultDateFormat());
}

public ApiClient(ObjectMapper mapper, DateFormat format) {
this(buildRestClient(mapper.copy()), format);
this(null, mapper, 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) {
this.restClient = restClient;
this.dateFormat = format;
this.objectMapper = createDefaultObjectMapper(format);
this.init();
this(restClient, createDefaultObjectMapper(format), format);
}

public static DateFormat createDefaultDateFormat() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,29 +84,26 @@ private String collectionToString(Collection<?> collection) {


public ApiClient() {
this.dateFormat = createDefaultDateFormat();
this.objectMapper = createDefaultObjectMapper(this.dateFormat);
this.restClient = buildRestClient(this.objectMapper);
this.init();
this(null);
}

public ApiClient(RestClient restClient) {
this(Optional.ofNullable(restClient).orElseGet(ApiClient::buildRestClient), createDefaultDateFormat());
this(restClient, createDefaultDateFormat());
}

public ApiClient(ObjectMapper mapper, DateFormat format) {
this(buildRestClient(mapper.copy()), format);
this(null, mapper, 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) {
this.restClient = restClient;
this.dateFormat = format;
this.objectMapper = createDefaultObjectMapper(format);
this.init();
this(restClient, createDefaultObjectMapper(format), format);
}

public static DateFormat createDefaultDateFormat() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,29 +85,26 @@ private String collectionToString(Collection<?> collection) {


public ApiClient() {
this.dateFormat = createDefaultDateFormat();
this.objectMapper = createDefaultObjectMapper(this.dateFormat);
this.restClient = buildRestClient(this.objectMapper);
this.init();
this(null);
}

public ApiClient(RestClient restClient) {
this(Optional.ofNullable(restClient).orElseGet(ApiClient::buildRestClient), createDefaultDateFormat());
this(restClient, createDefaultDateFormat());
}

public ApiClient(ObjectMapper mapper, DateFormat format) {
this(buildRestClient(mapper.copy()), format);
this(null, mapper, 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) {
this.restClient = restClient;
this.dateFormat = format;
this.objectMapper = createDefaultObjectMapper(format);
this.init();
this(restClient, createDefaultObjectMapper(format), format);
}

public static DateFormat createDefaultDateFormat() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,29 +85,26 @@ private String collectionToString(Collection<?> collection) {


public ApiClient() {
this.dateFormat = createDefaultDateFormat();
this.objectMapper = createDefaultObjectMapper(this.dateFormat);
this.restClient = buildRestClient(this.objectMapper);
this.init();
this(null);
}

public ApiClient(RestClient restClient) {
this(Optional.ofNullable(restClient).orElseGet(ApiClient::buildRestClient), createDefaultDateFormat());
this(restClient, createDefaultDateFormat());
}

public ApiClient(ObjectMapper mapper, DateFormat format) {
this(buildRestClient(mapper.copy()), format);
this(null, mapper, 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) {
this.restClient = restClient;
this.dateFormat = format;
this.objectMapper = createDefaultObjectMapper(format);
this.init();
this(restClient, createDefaultObjectMapper(format), format);
}

public static DateFormat createDefaultDateFormat() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,29 +85,26 @@ private String collectionToString(Collection<?> collection) {


public ApiClient() {
this.dateFormat = createDefaultDateFormat();
this.objectMapper = createDefaultObjectMapper(this.dateFormat);
this.restClient = buildRestClient(this.objectMapper);
this.init();
this(null);
}

public ApiClient(RestClient restClient) {
this(Optional.ofNullable(restClient).orElseGet(ApiClient::buildRestClient), createDefaultDateFormat());
this(restClient, createDefaultDateFormat());
}

public ApiClient(ObjectMapper mapper, DateFormat format) {
this(buildRestClient(mapper.copy()), format);
this(null, mapper, 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) {
this.restClient = restClient;
this.dateFormat = format;
this.objectMapper = createDefaultObjectMapper(format);
this.init();
this(restClient, createDefaultObjectMapper(format), format);
}

public static DateFormat createDefaultDateFormat() {
Expand Down

0 comments on commit a82475e

Please sign in to comment.