From 72a6ad4a6b23e6faa9668e7a75dd86f7f56fbae0 Mon Sep 17 00:00:00 2001 From: Lari Hotari Date: Thu, 22 Dec 2022 12:43:10 +0200 Subject: [PATCH 1/3] [fix][client] Prevent DNS reverse lookup when physical address is an IP address --- .../main/java/org/apache/pulsar/client/impl/ConnectionPool.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConnectionPool.java b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConnectionPool.java index da522020f5129..5e0a592cdc60b 100644 --- a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConnectionPool.java +++ b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConnectionPool.java @@ -274,7 +274,7 @@ private CompletableFuture createConnection(InetSocketAddress logicalA cnx.setTargetBroker(logicalAddress); } - cnx.setRemoteHostName(physicalAddress.getHostName()); + cnx.setRemoteHostName(physicalAddress.getHostString()); cnx.connectionFuture().thenRun(() -> { if (log.isDebugEnabled()) { From 94c761d18701958c96054fef8e9b1d41fdf1eb99 Mon Sep 17 00:00:00 2001 From: Lari Hotari Date: Thu, 22 Dec 2022 12:57:27 +0200 Subject: [PATCH 2/3] Also prevent DNS reverse lookup in PulsarServiceNameResolver --- .../apache/pulsar/client/impl/PulsarServiceNameResolver.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarServiceNameResolver.java b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarServiceNameResolver.java index 35c04ce27b192..32f5aa4975c6c 100644 --- a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarServiceNameResolver.java +++ b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarServiceNameResolver.java @@ -61,7 +61,7 @@ public InetSocketAddress resolveHost() { @Override public URI resolveHostUri() { InetSocketAddress host = resolveHost(); - String hostUrl = serviceUri.getServiceScheme() + "://" + host.getHostName() + ":" + host.getPort(); + String hostUrl = serviceUri.getServiceScheme() + "://" + host.getHostString() + ":" + host.getPort(); return URI.create(hostUrl); } From 6874f653e05e73f6fc602119a7466003732dc0a4 Mon Sep 17 00:00:00 2001 From: Lari Hotari Date: Thu, 22 Dec 2022 13:03:26 +0200 Subject: [PATCH 3/3] Also cover AsyncHttpConnector --- .../pulsar/client/admin/internal/http/AsyncHttpConnector.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/http/AsyncHttpConnector.java b/pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/http/AsyncHttpConnector.java index 6ae18724166f6..e79bacb4156b2 100644 --- a/pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/http/AsyncHttpConnector.java +++ b/pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/http/AsyncHttpConnector.java @@ -210,7 +210,7 @@ public void failure(Throwable failure) { private URI replaceWithNew(InetSocketAddress address, URI uri) { String originalUri = uri.toString(); String newUri = (originalUri.split(":")[0] + "://") - + address.getHostName() + ":" + + address.getHostString() + ":" + address.getPort() + uri.getRawPath(); if (uri.getRawQuery() != null) {