Skip to content

Fix bugs and resource leaks in Apache HttpClient protocol implementation#1863

Merged
jnioche merged 2 commits intomainfrom
apache-http
Apr 2, 2026
Merged

Fix bugs and resource leaks in Apache HttpClient protocol implementation#1863
jnioche merged 2 commits intomainfrom
apache-http

Conversation

@rzo1
Copy link
Copy Markdown
Contributor

@rzo1 rzo1 commented Apr 1, 2026

The proxy race condition fix (a08a456b) introduced two regressions:

  • The local builder for proxied requests lost:

    • Default headers
    • User-Agent
  • A new CloseableHttpClient was created on every request, even when no proxy was used

Fixes applied

  • Store userAgent and defaultHeaders as fields
  • Pass these fields to the proxy builder
  • Build the client once in configure() and reuse it for non-proxy requests

Additional fixes

  • Fix toByteArray() returning null when the entity input stream is null
  • Close the static CONNECTION_MANAGER in cleanup()
  • Wrap the entity InputStream in a try-with-resources block

The proxy race condition fix (a08a456) introduced two regressions:

The local builder for proxied requests lost:
Default headers
User-Agent
A new CloseableHttpClient was created on every request, even when no proxy was used
Fixes applied
Store userAgent and defaultHeaders as fields
Pass these fields to the proxy builder
Build the client once in configure() and reuse it for non-proxy requests
Additional fixes
Fix toByteArray() returning null when the entity input stream is null
Close the static CONNECTION_MANAGER in cleanup()
Wrap the entity InputStream in a try-with-resources block
@rzo1 rzo1 added this to the 3.5.2 milestone Apr 1, 2026
@rzo1 rzo1 requested a review from jnioche April 1, 2026 17:42
@jnioche jnioche added the bug label Apr 2, 2026
@jnioche jnioche merged commit d485783 into main Apr 2, 2026
2 checks passed
@jnioche jnioche deleted the apache-http branch April 2, 2026 06:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants