Skip to content

fix(datastore): avoid DNS lookup for default host in isLocalHost - #15413

Open
jinseopkim0 wants to merge 1 commit into
mainfrom
fix/datastore-is-local-host-dns
Open

jinseopkim0 wants to merge 1 commit into
mainfrom
fix/datastore-is-local-host-dns

Conversation

@jinseopkim0

@jinseopkim0 jinseopkim0 commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

b/588887355#comment11

Avoid DNS lookups for default Datastore hosts, localhost, and IP literals in DatastoreUtils.isLocalHost(), return false on UnknownHostException, and reuse it in HttpDatastoreRpc.

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

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.

Code Review

This pull request refactors and optimizes the isLocalHost check in DatastoreUtils to avoid unnecessary DNS lookups. It short-circuits the default Datastore hostname, handles literal localhost and numeric IPv4/IPv6 addresses directly, and catches exceptions to fail open instead of throwing a runtime exception. Additionally, duplicate helper methods in HttpDatastoreRpc have been removed in favor of static imports, and new unit tests have been added to verify the updated behavior. I have no feedback to provide.

This branch has not been deployed

No deployments
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