test(storage): bind FakeServer and TestBench to 127.0.0.1 to avoid localhost hangs #13386
test(storage): bind FakeServer and TestBench to 127.0.0.1 to avoid localhost hangs #13386Dhriti07 wants to merge 4 commits into
Conversation
…calhost IPv6 hangs
There was a problem hiding this comment.
Code Review
This pull request replaces "localhost" with "127.0.0.1" in FakeServer.java and TestBench.java to resolve potential localhost DNS resolution issues. The reviewer suggests using InetAddress.getLoopbackAddress() instead of hardcoding "127.0.0.1" in FakeServer.java to ensure robust compatibility with both IPv4 and IPv6 loopback environments.
|
|
||
| static FakeServer of(StorageGrpc.StorageImplBase service) throws IOException { | ||
| InetSocketAddress address = new InetSocketAddress("localhost", 0); | ||
| InetSocketAddress address = new InetSocketAddress("127.0.0.1", 0); |
There was a problem hiding this comment.
Instead of hardcoding the IPv4 loopback address "127.0.0.1", consider using InetAddress.getLoopbackAddress(). This is more robust as it dynamically resolves to the correct loopback address (IPv4 or IPv6) for the environment without performing a DNS lookup, which avoids the localhost resolution hangs while maintaining compatibility with IPv6-only loopback environments.
| InetSocketAddress address = new InetSocketAddress("127.0.0.1", 0); | |
| InetSocketAddress address = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0); |
Bind FakeServer and TestBench to 127.0.0.1 to avoid localhost hangs