Skip to content

fix(http): trim nonProxyHosts entry whitespace - #7267

Merged
zoewangg merged 2 commits into
masterfrom
zoewang/nonproxyhosts-trim-space
Aug 13, 2026
Merged

fix(http): trim nonProxyHosts entry whitespace#7267
zoewangg merged 2 commits into
masterfrom
zoewang/nonproxyhosts-trim-space

Conversation

@zoewangg

Copy link
Copy Markdown
Contributor

Motivation and Context

nonProxyHosts / no_proxy values are pipe- or comma-separated lists, and users commonly write them with spaces after the separator, e.g.:

export no_proxy="example.com, *.foo.com, 10.0.0.0/8"
-Dhttp.nonProxyHosts="example.com | *.foo.com"

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 defeated no_proxy for any list written with the conventional comma-space style.

Modifications

  • Fix (behavior): SdkHttpUtils.extractNonProxyHosts now 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 nonProxyHosts entries 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

  • Shared cross-client suite: added a comma-space no_proxy case to ProxyConfigCommonTestData (drives HttpProxyTestSuite for all five clients) asserting each entry resolves with surrounding whitespace trimmed.
  • Netty routing: added ProxyWireMockTest.proxyConfigured_hostInCommaSpaceNoProxyEnv_doesNotConnect, verifying a host listed in a comma-space no_proxy bypasses the proxy end to end.
  • Unit: added SdkHttpUtilsTest cases for comma-space entries, surrounding whitespace on a single entry, and the no-whitespace regression (unchanged behavior preserved).

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • I have added a changelog entry. Adding a new entry must be accomplished by running the scripts/new-change script and following the instructions. Commit the new file created by the script in .changes/next-release with your changes.
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • I confirm that this pull request can be released under the Apache 2 license

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.
@zoewangg
zoewangg requested a review from a team as a code owner August 12, 2026 22:39
Comment thread utils/src/test/java/software/amazon/awssdk/utils/SdkHttpUtilsTest.java Outdated
@zoewangg
zoewangg requested a review from davidh44 August 12, 2026 23:05
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.
@zoewangg zoewangg added the no-api-surface-area-change Indicate there is no API surface area change and thus API surface area review is not required label Aug 12, 2026
@zoewangg
zoewangg enabled auto-merge August 13, 2026 00:07
@zoewangg
zoewangg added this pull request to the merge queue Aug 13, 2026
Merged via the queue into master with commit 439d174 Aug 13, 2026
15 of 17 checks passed
@github-actions

Copy link
Copy Markdown

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.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Aug 13, 2026
@zoewangg
zoewangg deleted the zoewang/nonproxyhosts-trim-space branch August 13, 2026 16:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

no-api-surface-area-change Indicate there is no API surface area change and thus API surface area review is not required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants