This is an automated email from the ASF dual-hosted git repository. jamesnetherton pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push: new 4a262c49a9 Handle ipv6 addresses for JolokiaRequestRedirectHandler 4a262c49a9 is described below commit 4a262c49a99bafae51029add6b8bc8a00fb2d867 Author: James Netherton <jamesnether...@gmail.com> AuthorDate: Fri Mar 7 08:37:06 2025 +0000 Handle ipv6 addresses for JolokiaRequestRedirectHandler Fixes #7102 --- .../org/apache/camel/quarkus/jolokia/JolokiaRecorder.java | 13 +++++++++++-- .../camel/quarkus/component/jolokia/it/JolokiaTest.java | 13 ++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/extensions/jolokia/runtime/src/main/java/org/apache/camel/quarkus/jolokia/JolokiaRecorder.java b/extensions/jolokia/runtime/src/main/java/org/apache/camel/quarkus/jolokia/JolokiaRecorder.java index c2e1cf6ce5..081a6aa422 100644 --- a/extensions/jolokia/runtime/src/main/java/org/apache/camel/quarkus/jolokia/JolokiaRecorder.java +++ b/extensions/jolokia/runtime/src/main/java/org/apache/camel/quarkus/jolokia/JolokiaRecorder.java @@ -182,13 +182,22 @@ public class JolokiaRecorder { } static String resolveHost(InetAddress address) { + String host; if (address == null) { try { - return HostUtils.getLocalHostName(); + host = HostUtils.getLocalHostName(); } catch (UnknownHostException e) { throw new IllegalStateException("Unable to determine the Jolokia host", e); } + } else { + host = address.getHostName(); } - return address.getHostName(); + + // ipv6 address + if (host.contains(":")) { + host = "[%s]".formatted(host); + } + + return host; } } diff --git a/integration-tests/jolokia/src/test/java/org/apache/camel/quarkus/component/jolokia/it/JolokiaTest.java b/integration-tests/jolokia/src/test/java/org/apache/camel/quarkus/component/jolokia/it/JolokiaTest.java index 6ea2d18e07..9f414a91d5 100644 --- a/integration-tests/jolokia/src/test/java/org/apache/camel/quarkus/component/jolokia/it/JolokiaTest.java +++ b/integration-tests/jolokia/src/test/java/org/apache/camel/quarkus/component/jolokia/it/JolokiaTest.java @@ -24,6 +24,8 @@ import org.apache.camel.quarkus.jolokia.restrictor.CamelJolokiaRestrictor; import org.eclipse.microprofile.config.ConfigProvider; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.greaterThanOrEqualTo; @@ -37,10 +39,15 @@ class JolokiaTest { RestAssured.port = 8778; } - @Test - void defaultConfiguration() { + @ParameterizedTest + @ValueSource(strings = { "/jolokia/", "/q/jolokia" }) + void defaultConfiguration(String path) { + if (path.startsWith("/q")) { + RestAssured.port = ConfigProvider.getConfig().getValue("quarkus.http.test-port", Integer.class); + } + RestAssured.given() - .get("/jolokia/") + .get(path) .then() .statusCode(200) .body(