Skip to content

test(storage): bind FakeServer and TestBench to 127.0.0.1 to avoid localhost hangs #13386

Open
Dhriti07 wants to merge 12 commits into
mainfrom
fix-testbench-localhost-hang
Open

test(storage): bind FakeServer and TestBench to 127.0.0.1 to avoid localhost hangs #13386
Dhriti07 wants to merge 12 commits into
mainfrom
fix-testbench-localhost-hang

Conversation

@Dhriti07
Copy link
Copy Markdown
Contributor

@Dhriti07 Dhriti07 commented Jun 8, 2026

Bind FakeServer and TestBench to 127.0.0.1 to avoid localhost hangs

@Dhriti07 Dhriti07 requested review from a team as code owners June 8, 2026 09:53
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
InetSocketAddress address = new InetSocketAddress("127.0.0.1", 0);
InetSocketAddress address = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant