This is an automated email from the ASF dual-hosted git repository. orpiske pushed a commit to branch camel-4.18.x in repository https://gitbox.apache.org/repos/asf/camel.git
commit 77e99e92d318a24171d0fe43a5c9156b9a89c0bf Author: Claude <[email protected]> AuthorDate: Mon Oct 26 09:17:58 2026 +0000 CAMEL-26108: camel-avro-rpc - address review comments Use 127.0.0.2 in the test instead of looking up a non-loopback address, so it always runs, and remove trailing whitespace in the upgrade guide. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit aa2c0c3687da0ee0bfedd8c0721a844b5c8a535d) --- .../component/avro/AvroHttpConsumerHostTest.java | 33 ++++------------------ .../ROOT/pages/camel-4x-upgrade-guide-4_18.adoc | 3 +- 2 files changed, 6 insertions(+), 30 deletions(-) diff --git a/components/camel-avro-rpc/camel-avro-rpc-component/src/test/java/org/apache/camel/component/avro/AvroHttpConsumerHostTest.java b/components/camel-avro-rpc/camel-avro-rpc-component/src/test/java/org/apache/camel/component/avro/AvroHttpConsumerHostTest.java index 53253fc2d534..7706cc6d58dc 100644 --- a/components/camel-avro-rpc/camel-avro-rpc-component/src/test/java/org/apache/camel/component/avro/AvroHttpConsumerHostTest.java +++ b/components/camel-avro-rpc/camel-avro-rpc-component/src/test/java/org/apache/camel/component/avro/AvroHttpConsumerHostTest.java @@ -17,19 +17,14 @@ package org.apache.camel.component.avro; import java.io.IOException; -import java.net.Inet4Address; -import java.net.InetAddress; import java.net.InetSocketAddress; -import java.net.NetworkInterface; import java.net.Socket; -import java.net.SocketException; import org.apache.camel.builder.RouteBuilder; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assumptions.assumeTrue; /** * The http consumer listens on the host of the endpoint, as the netty consumer does. @@ -49,32 +44,14 @@ public class AvroHttpConsumerHostTest extends AvroTestSupport { } @Test - public void testListensOnConfiguredHostOnly() throws Exception { - InetAddress other = findNonLoopbackAddress(); - assumeTrue(other != null, "No non-loopback IPv4 address available"); - - assertDoesNotThrow(() -> connect(InetAddress.getByName("127.0.0.1"))); - assertThrows(IOException.class, () -> connect(other)); + public void testListensOnConfiguredHostOnly() { + assertDoesNotThrow(() -> connect("127.0.0.1")); + assertThrows(IOException.class, () -> connect("127.0.0.2")); } - private void connect(InetAddress address) throws IOException { + private void connect(String host) throws IOException { try (Socket socket = new Socket()) { - socket.connect(new InetSocketAddress(address, avroPort), 2000); + socket.connect(new InetSocketAddress(host, avroPort), 2000); } } - - private static InetAddress findNonLoopbackAddress() throws SocketException { - return NetworkInterface.networkInterfaces() - .filter(nic -> { - try { - return nic.isUp() && !nic.isLoopback(); - } catch (SocketException e) { - return false; - } - }) - .flatMap(NetworkInterface::inetAddresses) - .filter(address -> address instanceof Inet4Address && !address.isLoopbackAddress()) - .findFirst() - .orElse(null); - } } diff --git a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_18.adoc b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_18.adoc index 9333e7beb726..3ff0f9897ce7 100644 --- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_18.adoc +++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_18.adoc @@ -1878,9 +1878,8 @@ likely to be affected. === camel-avro-rpc - the http consumer listens on the host of the endpoint -The `avro:http` consumer now uses the host of the endpoint URI (`avro:http:[host]:[port]`) for its HTTP server, as the `avro:netty` consumer does. +The `avro:http` consumer now uses the host of the endpoint URI (`avro:http:[host]:[port]`) for its HTTP server, as the `avro:netty` consumer does. Use `0.0.0.0` as the host to accept connections on all network interfaces. `AvroRpcHttpServerFactory` has a new method `create(SpecificResponder, String, int)` that receives the host. A custom factory should implement it. -
