From 4bdd412fd8c14e6df44968b40d270c5f9351b73a Mon Sep 17 00:00:00 2001 From: capistrant Date: Tue, 26 Aug 2025 16:24:38 -0500 Subject: [PATCH 1/3] Provide ability to give http client builder a base web options config when using vertx builder --- .../client/vertx/VertxHttpClientBuilder.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/httpclient-vertx/src/main/java/io/fabric8/kubernetes/client/vertx/VertxHttpClientBuilder.java b/httpclient-vertx/src/main/java/io/fabric8/kubernetes/client/vertx/VertxHttpClientBuilder.java index 7ea942dec07..72b1ccbdf2b 100644 --- a/httpclient-vertx/src/main/java/io/fabric8/kubernetes/client/vertx/VertxHttpClientBuilder.java +++ b/httpclient-vertx/src/main/java/io/fabric8/kubernetes/client/vertx/VertxHttpClientBuilder.java @@ -50,6 +50,7 @@ public class VertxHttpClientBuilder final Vertx vertx; private final boolean closeVertx; + private WebClientOptions customWebClientOptions; public VertxHttpClientBuilder(F clientFactory, Vertx sharedVertx) { this( @@ -64,13 +65,31 @@ public VertxHttpClientBuilder(F clientFactory, Vertx sharedVertx) { this.closeVertx = closeVertx; } + /** + * Use the provided {@link WebClientOptions} as the base options for the client. + *

+ * Note: The Builder overrides some options to ensure the client works properly with the Kubernetes API server. + * These options that the Builder controls will override the values you set in the provided + * {@link WebClientOptions}. + *

+ */ + public VertxHttpClientBuilder withCustomWebClientOptions(WebClientOptions options) { + this.customWebClientOptions = options; + return this; + } + @Override public VertxHttpClient build() { if (this.client != null) { return new VertxHttpClient<>(this, this.client.getClosed(), this.client.getClient(), closeVertx); } - WebClientOptions options = new WebClientOptions(); + WebClientOptions options; + if (customWebClientOptions == null) { + options = new WebClientOptions(); + } else { + options = new WebClientOptions(customWebClientOptions); + } options.setMaxPoolSize(MAX_CONNECTIONS); options.setMaxWebSockets(MAX_CONNECTIONS); From 508b0f5d5ceee313d91ea777ba1a47f25016e7b0 Mon Sep 17 00:00:00 2001 From: capistrant Date: Fri, 26 Sep 2025 13:19:08 -0500 Subject: [PATCH 2/3] UT to confirm HttpClient build doesn't blow up when using customWebOptions --- .../vertx/VertxHttpClientBuilderTest.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/httpclient-vertx/src/test/java/io/fabric8/kubernetes/client/vertx/VertxHttpClientBuilderTest.java b/httpclient-vertx/src/test/java/io/fabric8/kubernetes/client/vertx/VertxHttpClientBuilderTest.java index f42ec8b8b2c..87f099e601e 100644 --- a/httpclient-vertx/src/test/java/io/fabric8/kubernetes/client/vertx/VertxHttpClientBuilderTest.java +++ b/httpclient-vertx/src/test/java/io/fabric8/kubernetes/client/vertx/VertxHttpClientBuilderTest.java @@ -18,6 +18,7 @@ import io.fabric8.kubernetes.client.http.HttpClient; import io.vertx.core.Vertx; import io.vertx.core.impl.VertxImpl; +import io.vertx.ext.web.client.WebClientOptions; import org.assertj.core.api.InstanceOfAssertFactories; import org.junit.jupiter.api.Test; @@ -81,4 +82,24 @@ void closesVertxInstanceWhenClientIsClosed() { .asInstanceOf(InstanceOfAssertFactories.type(VertxImpl.class)) .returns(true, vi -> vi.closeFuture().isClosed()); } + + @Test + void buildsSuccessfullyWithCustomWebClientOptions() { + WebClientOptions customOptions = new WebClientOptions() + .setKeepAlive(false) + .setTcpNoDelay(false) + .setUserAgent("custom-agent"); + + VertxHttpClientFactory factory = new VertxHttpClientFactory(); + VertxHttpClientBuilder builder = factory.newBuilder(); + + try (HttpClient client = builder.withCustomWebClientOptions(customOptions).build()) { + assertThat(client) + .isInstanceOf(VertxHttpClient.class) + .isNotNull(); + + assertThat(client.newHttpRequestBuilder().uri("http://localhost").build()) + .isNotNull(); + } + } } From d32998bbf566916a7ff8174f370ea75f26f993d8 Mon Sep 17 00:00:00 2001 From: capistrant Date: Fri, 26 Sep 2025 21:56:10 -0500 Subject: [PATCH 3/3] add changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e7b526389f..7708eef361c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ #### Dependency Upgrade #### New Features +* Fix #7252: Allow VertxHttpClientBuilder to be seeded with a base WebClientOptions object, allowing more customization of the Vertx HTTP Client #### _**Note**_: Breaking changes