Skip to content

Replacing www.example.com in OkHttp Client test to fix flakiness - #27277

Open
dennisoelkers wants to merge 2 commits into
masterfrom
fix-okhttpclientprovider-test-flakiness
Open

dennisoelkers wants to merge 2 commits into
masterfrom
fix-okhttpclientprovider-test-flakiness

Conversation

@dennisoelkers

@dennisoelkers dennisoelkers commented Sep 4, 2026

Copy link
Copy Markdown
Member

Description

Motivation and Context

Previously, in the OkHttpClientProviderTest, a dummy value of www.example.com was used for testing proxy configuration. This lead to unnecessary DNS lookups (in ProxySelectorProvider's implementation of ProxySelector#select) and therefore flakiness. This change is now replacing this with the use of an IP (that is designated for use in tests) and reenables the test.

/nocl Internal refactoring.

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (non-breaking change)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have requested a documentation update.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

The class (and two of its methods) has been @Ignore/@disabled since
#7644 and #7799 (2020) for producing intermittent CI failures. The
tests all target the real hostname www.example.com, and
ProxySelectorProvider#get() resolves the request host with
InetAddress.getByName() on every proxy selection -- a live, blocking
DNS lookup as a side effect of running the suite. That's a plausible
and well-fitting explanation for years of "fails every now and then":
it depends on outbound DNS being fast and reliable in CI, which it
isn't always.

Swap the target for 203.0.113.10 (RFC 5737 TEST-NET-3, a
documentation-only address that InetAddress.getByName() resolves
without a network call) and drop the @disabled annotations. Ran the
suite 8 times back to back locally: 14/14 passing, 0 failures, every
time.
Review feedback: the DNS lookup happens in the ProxySelector.select()
override that ProxySelectorProvider#get() returns, not in get() itself.
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