Skip to content

Short-circuit empty cookie store lookups - #2261

Closed
pavel-ptashyts wants to merge 1 commit into
AsyncHttpClient:mainfrom
maygemdev:perf/cookie-empty-jar-short-circuit
Closed

pavel-ptashyts wants to merge 1 commit into
AsyncHttpClient:mainfrom
maygemdev:perf/cookie-empty-jar-short-circuit

Conversation

@pavel-ptashyts

Copy link
Copy Markdown
Contributor

Summary

  • Return an empty cookie list immediately when ThreadSafeCookieStore has no retained cookies.
  • Keep null handling explicit with requireNonNull(uri, "uri") before the shortcut.
  • Add coverage for get(Uri) on an empty store.

Motivation

The default cookie store is consulted for each request. When no cookies have been stored, the lookup does not need to normalize the request host, derive the request path, or scan subdomains.

Validation

  • /opt/maven/bin/mvn -pl client -DskipTests compile
  • /opt/maven/bin/mvn -pl client -Dtest=ThreadSafeCookieStoreGetTest test

Return an empty cookie list immediately when ThreadSafeCookieStore has no retained cookies. This avoids request host normalization, path lookup, and subdomain scanning on the common empty-jar path while preserving null handling with an explicit Uri null check.

Add coverage for get(Uri) on an empty store.

Verified with:\n- /opt/maven/bin/mvn -pl client -DskipTests compile\n- /opt/maven/bin/mvn -pl client -Dtest=ThreadSafeCookieStoreGetTest test
@pavel-ptashyts

Copy link
Copy Markdown
Contributor Author

Closing because this performance change will not be pursued.

@pavel-ptashyts
pavel-ptashyts deleted the perf/cookie-empty-jar-short-circuit branch July 19, 2026 16:27
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