Skip to content

Close response body in JdkHttpSender on unsupported Content-Encoding - #8962

Merged
jack-berg merged 1 commit into
open-telemetry:mainfrom
thswlsqls:fix/jdk-sender-close-body-on-unsupported-encoding
Oct 19, 2026
Merged

jack-berg merged 1 commit into
open-telemetry:mainfrom
thswlsqls:fix/jdk-sender-close-body-on-unsupported-encoding

Conversation

@thswlsqls

Copy link
Copy Markdown
Contributor

Fixes #8960

Description

  • JdkHttpSender.toHttpResponse() threw UnsupportedContentEncodingException before try (InputStream rawIs = response.body()), so the BodyHandlers.ofInputStream() body was never closed. Its Javadoc requires reading to EOF or calling close() to release the exchange.
  • The throw now sits inside try (InputStream ignored = response.body()). Exception type, message, and non-retryable handling are unchanged.
  • OkHttpHttpSender.handleResponse() already does this check inside try (ResponseBody body = ...).
  • Closing before EOF may close the connection instead of reusing it. That is intended for a non-conforming response, and OkHttp does the same.
  • The check and ofInputStream() both came in Response body bounds #8224. Internal package; no apidiff.

Testing done

  • Added JdkHttpSenderTest#sendInternal_unsupportedContentEncoding_closesBody: a mocked Content-Encoding: br response must throw and close the body. With the main-code fix reverted, it fails on the close assertion.
  • :exporters:sender:jdk:check: spotless, ErrorProne/NullAway and jApiCmp pass; 14 of 15 tests pass. sendInternal_RetryableConnectTimeoutException also fails on unmodified main here, because my VPN routes 10.255.255.1.

@thswlsqls
thswlsqls marked this pull request as ready for review October 18, 2026 13:07
@thswlsqls
thswlsqls requested a review from a team as a code owner October 18, 2026 13:07
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Merged · refreshed 2026-10-19 19:00 UTC

Status above doesn't look right?
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

@codecov

codecov Bot commented Oct 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.41%. Comparing base (b32298a) to head (2578723).

Files with missing lines Patch % Lines
...ry/exporter/sender/jdk/internal/JdkHttpSender.java 50.00% 0 Missing and 1 partial ⚠️

❌ Your patch check has failed because the patch coverage (50.00%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #8962   +/-   ##
=========================================
  Coverage     90.40%   90.41%           
- Complexity    10898    10900    +2     
=========================================
  Files          1015     1015           
  Lines         29843    29844    +1     
  Branches       3896     3897    +1     
=========================================
+ Hits          26981    26982    +1     
  Misses         1910     1910           
  Partials        952      952           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jack-berg
jack-berg merged commit fe1e735 into open-telemetry:main Oct 19, 2026
34 of 35 checks passed
@otelbot

otelbot Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution @thswlsqls! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey.

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.

JdkHttpSender does not close the response body on unsupported Content-Encoding

2 participants