hangc0276 opened a new pull request, #16152:
URL: https://github.com/apache/pulsar/pull/16152

   ### Motivation
   When running a Pulsar client with auto cluster failover, it will throw the 
following exception when detecting the pulsar service URL.
   ```
   2022-06-21T09:59:52,646+0800 WARN  [main] 
o.a.p.c.i.AutoClusterFailoverTest@328 - Failed to probe available, url: 
pulsar://localhost:11195 
   java.net.UnknownHostException: localhost
        at 
java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184) 
~[?:1.8.0_131]
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) 
~[?:1.8.0_131]
        at java.net.Socket.connect(Socket.java:589) ~[?:1.8.0_131]
        at 
org.apache.pulsar.client.impl.AutoClusterFailoverTest.testUrl(AutoClusterFailoverTest.java:324)
 ~[test-classes/:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
~[?:1.8.0_131]
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
~[?:1.8.0_131]
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 ~[?:1.8.0_131]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_131]
        at 
org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:132)
 ~[testng-7.3.0.jar:?]
        at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:599) 
~[testng-7.3.0.jar:?]
        at 
org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:174) 
~[testng-7.3.0.jar:?]
        at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46) 
~[testng-7.3.0.jar:?]
        at 
org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:822)
 ~[testng-7.3.0.jar:?]
        at 
org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:147) 
~[testng-7.3.0.jar:?]
        at 
org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
 ~[testng-7.3.0.jar:?]
        at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128) 
~[testng-7.3.0.jar:?]
        at java.util.ArrayList.forEach(ArrayList.java:1249) [?:1.8.0_131]
        at org.testng.TestRunner.privateRun(TestRunner.java:764) 
[testng-7.3.0.jar:?]
        at org.testng.TestRunner.run(TestRunner.java:585) [testng-7.3.0.jar:?]
        at org.testng.SuiteRunner.runTest(SuiteRunner.java:384) 
[testng-7.3.0.jar:?]
        at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:378) 
[testng-7.3.0.jar:?]
        at org.testng.SuiteRunner.privateRun(SuiteRunner.java:337) 
[testng-7.3.0.jar:?]
        at org.testng.SuiteRunner.run(SuiteRunner.java:286) [testng-7.3.0.jar:?]
        at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53) 
[testng-7.3.0.jar:?]
        at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96) 
[testng-7.3.0.jar:?]
        at org.testng.TestNG.runSuitesSequentially(TestNG.java:1218) 
[testng-7.3.0.jar:?]
        at org.testng.TestNG.runSuitesLocally(TestNG.java:1140) 
[testng-7.3.0.jar:?]
        at org.testng.TestNG.runSuites(TestNG.java:1069) [testng-7.3.0.jar:?]
        at org.testng.TestNG.run(TestNG.java:1037) [testng-7.3.0.jar:?]
        at 
com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:66) 
[testng-rt.jar:?]
        at 
com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:109) 
[testng-rt.jar:?]
   ```
   
   It was introduced by https://github.com/apache/pulsar/pull/14454. 
   
   The root cause is that the `resolver.resolveHost()` will return the 
InetSocketAddress which doesn't resolve the IP address.
   
https://github.com/apache/pulsar/blob/603a5cdd8e4f82a27c1341c93eb6162862d1e970/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarServiceNameResolver.java#L94
   It can't be applied to the HTTP endpoint the detect the IP: Port active.
   
   ### Modification
   Use `InetSocketAddress` object instead of `resolver.resolveHost()`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to