Skip to content

Commit

Permalink
fix fabric8io#4471: still need to apply config even with default factory
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Oct 17, 2022
1 parent e477bc3 commit 174c366
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Expand Up @@ -18,6 +18,7 @@

import io.fabric8.kubernetes.client.http.HttpClient;
import io.fabric8.kubernetes.client.informers.ResourceEventHandler;
import io.fabric8.kubernetes.client.utils.HttpClientUtils;
import io.fabric8.kubernetes.client.utils.Serialization;

import java.io.InputStream;
Expand Down Expand Up @@ -72,7 +73,7 @@ public KubernetesClient build() {
}
try {
if (factory == null) {
return clazz.getConstructor(Config.class).newInstance(config);
this.factory = HttpClientUtils.getHttpClientFactory();
}
HttpClient client = getHttpClient();
return clazz.getConstructor(HttpClient.class, Config.class, ExecutorSupplier.class).newInstance(client, config,
Expand Down
Expand Up @@ -142,6 +142,11 @@ public static String basicCredentials(String username, String password) {
*/
@Deprecated
public static HttpClient createHttpClient(Config config) {
HttpClient.Factory factory = getHttpClientFactory();
return factory.newBuilder(config).build();
}

public static HttpClient.Factory getHttpClientFactory() {
ServiceLoader<HttpClient.Factory> loader = ServiceLoader.load(HttpClient.Factory.class);
HttpClient.Factory factory = null;
for (Iterator<HttpClient.Factory> iter = loader.iterator(); iter.hasNext();) {
Expand All @@ -159,7 +164,7 @@ public static HttpClient createHttpClient(Config config) {
throw new KubernetesClientException(
"No httpclient implementations found on the context classloader, please ensure your classpath includes an implementation jar");
}
return factory.newBuilder(config).build();
return factory;
}

public static void applyCommonConfiguration(Config config, HttpClient.Builder builder, HttpClient.Factory factory) {
Expand Down

0 comments on commit 174c366

Please sign in to comment.