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)
  • Loading branch information
CaptainAye committed Oct 6, 2024
1 parent 2f73582 commit ef8fe30
Showing 1 changed file with 8 additions and 11 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

0 comments on commit ef8fe30

Please sign in to comment.