fix(http): trim nonProxyHosts entry whitespace - #7267
Merged
Conversation
Whitespace around comma- or pipe-separated no_proxy / http.nonProxyHosts entries was treated as part of the host name and never matched, so the host was proxied. Trim each entry in the shared SdkHttpUtils parser; also documents the nonProxyHosts wildcard contract.
davidh44
approved these changes
Aug 12, 2026
parseListOfNonProxyHostWithoutWhitespace_isUnchanged duplicated the existing parseListOfNonProxyHostWithCommasAndWildCard (same no-whitespace input and assertions). The no-whitespace regression is already covered there; the whitespace-trim behavior is covered by the comma-space and single-host trim tests.
davidh44
approved these changes
Aug 12, 2026
|
This pull request has been closed and the conversation has been locked. Comments on closed PRs are hard for our team to see. If you need more assistance, please open a new issue that references this one. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
nonProxyHosts/no_proxyvalues are pipe- or comma-separated lists, and users commonly write them with spaces after the separator, e.g.:The shared parser (
SdkHttpUtils) split these lists but did not trim the resulting entries, so an entry with a leading (or trailing) space, e.g." *.foo.com", was stored with the space as part of the host name. It then never matched the real host, so the host was routed through the proxy instead of bypassing it. This silently defeatedno_proxyfor any list written with the conventional comma-space style.Modifications
Fix (behavior):
SdkHttpUtils.extractNonProxyHostsnow trims each entry (.map(String::trim)) after splitting, before lowercasing and the glob-to-regex rewrite. This shared parser feeds the four Java-regex clients (netty-nio,apache,apache5,url-connection) on the system-property (http.nonProxyHosts) and environment-variable (no_proxy/NO_PROXY) resolution paths, so the fix applies to those four uniformly.Documentation (no behavior change): added documentation
CRT scope (why no CRT changelog entry): CRT already trims
nonProxyHostsentries via its own path (rawNonProxyHosts()→ProxyUtils.splitToGlobTokens) as of the merged CRT wildcard change, so this PR's shared-parser trim does not change CRT behavior — it affects only the four Java-regex clients. The changelog therefore has four entries (one per regex client) and no CRT entry.No public API surface changes; builder-supplied nonProxyHosts semantics are unchanged (documented, not altered).
Testing
no_proxycase toProxyConfigCommonTestData(drivesHttpProxyTestSuitefor all five clients) asserting each entry resolves with surrounding whitespace trimmed.ProxyWireMockTest.proxyConfigured_hostInCommaSpaceNoProxyEnv_doesNotConnect, verifying a host listed in a comma-spaceno_proxybypasses the proxy end to end.SdkHttpUtilsTestcases for comma-space entries, surrounding whitespace on a single entry, and the no-whitespace regression (unchanged behavior preserved).Types of changes
Checklist
mvn installsucceedsscripts/new-changescript and following the instructions. Commit the new file created by the script in.changes/next-releasewith your changes.License