Skip to content

Commit

Permalink
Rest client classic: make configuration methods in RestClientBase pro…
Browse files Browse the repository at this point in the history
…tected

This is to accommodate kogito extension that accesses these methods.
  • Loading branch information
TomasHofman authored and Alasdair Preston committed Sep 14, 2022
1 parent 8e4d836 commit 28e2306
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public Object create() {
return builder.build(proxyType);
}

void configureBuilder(RestClientBuilder builder) {
protected void configureBuilder(RestClientBuilder builder) {
configureBaseUrl(builder);
configureTimeouts(builder);
configureProviders(builder);
Expand All @@ -77,7 +77,7 @@ void configureBuilder(RestClientBuilder builder) {
configureCustomProperties(builder);
}

private void configureCustomProperties(RestClientBuilder builder) {
protected void configureCustomProperties(RestClientBuilder builder) {
Optional<Integer> connectionPoolSize = oneOf(clientConfigByClassName().connectionPoolSize,
clientConfigByConfigKey().connectionPoolSize, configRoot.connectionPoolSize);
if (connectionPoolSize.isPresent()) {
Expand All @@ -92,7 +92,7 @@ private void configureCustomProperties(RestClientBuilder builder) {
}
}

private void configureProxy(RestClientBuilder builder) {
protected void configureProxy(RestClientBuilder builder) {
Optional<String> proxyAddress = oneOf(clientConfigByClassName().proxyAddress, clientConfigByConfigKey().proxyAddress,
configRoot.proxyAddress);
if (proxyAddress.isPresent() && !NONE.equals(proxyAddress.get())) {
Expand All @@ -116,23 +116,23 @@ private void configureProxy(RestClientBuilder builder) {
}
}

private void configureRedirects(RestClientBuilder builder) {
protected void configureRedirects(RestClientBuilder builder) {
Optional<Boolean> followRedirects = oneOf(clientConfigByClassName().followRedirects,
clientConfigByConfigKey().followRedirects, configRoot.followRedirects);
if (followRedirects.isPresent()) {
builder.followRedirects(followRedirects.get());
}
}

private void configureQueryParamStyle(RestClientBuilder builder) {
protected void configureQueryParamStyle(RestClientBuilder builder) {
Optional<QueryParamStyle> queryParamStyle = oneOf(clientConfigByClassName().queryParamStyle,
clientConfigByConfigKey().queryParamStyle, configRoot.queryParamStyle);
if (queryParamStyle.isPresent()) {
builder.queryParamStyle(queryParamStyle.get());
}
}

private void configureSsl(RestClientBuilder builder) {
protected void configureSsl(RestClientBuilder builder) {
Optional<String> trustStore = oneOf(clientConfigByClassName().trustStore, clientConfigByConfigKey().trustStore,
configRoot.trustStore);
if (trustStore.isPresent() && !trustStore.get().isBlank() && !NONE.equals(trustStore.get())) {
Expand Down Expand Up @@ -249,7 +249,7 @@ private InputStream locateStream(String path) throws FileNotFoundException {
}
}

private void configureProviders(RestClientBuilder builder) {
protected void configureProviders(RestClientBuilder builder) {
Optional<String> providers = oneOf(clientConfigByClassName().providers, clientConfigByConfigKey().providers,
configRoot.providers);

Expand Down Expand Up @@ -277,7 +277,7 @@ private Class<?> providerClassForName(String name) {
}
}

private void configureTimeouts(RestClientBuilder builder) {
protected void configureTimeouts(RestClientBuilder builder) {
Long connectTimeout = oneOf(clientConfigByClassName().connectTimeout,
clientConfigByConfigKey().connectTimeout).orElse(this.configRoot.connectTimeout);
if (connectTimeout != null) {
Expand All @@ -291,7 +291,7 @@ private void configureTimeouts(RestClientBuilder builder) {
}
}

private void configureBaseUrl(RestClientBuilder builder) {
protected void configureBaseUrl(RestClientBuilder builder) {
Optional<String> baseUrlOptional = oneOf(clientConfigByClassName().uri, clientConfigByConfigKey().uri);
if (baseUrlOptional.isEmpty()) {
baseUrlOptional = oneOf(clientConfigByClassName().url, clientConfigByConfigKey().url);
Expand Down Expand Up @@ -333,7 +333,7 @@ private RestClientConfig clientConfigByClassName() {
@SafeVarargs
private static <T> Optional<T> oneOf(Optional<T>... optionals) {
for (Optional<T> o : optionals) {
if (o.isPresent()) {
if (o != null && o.isPresent()) {
return o;
}
}
Expand Down

0 comments on commit 28e2306

Please sign in to comment.