Skip to content

Standardize JdkHttpSender shutdown to await executor termination#8627

Draft
thswlsqls wants to merge 1 commit into
open-telemetry:mainfrom
thswlsqls:fix/jdk-sender-shutdown-await-termination
Draft

Standardize JdkHttpSender shutdown to await executor termination#8627
thswlsqls wants to merge 1 commit into
open-telemetry:mainfrom
thswlsqls:fix/jdk-sender-shutdown-await-termination

Conversation

@thswlsqls

Copy link
Copy Markdown
Contributor

Related to #8280 — continues #8495

Description

  • shutdown() used graceful executorService.shutdown(), which does not interrupt workers sleeping in the retry backoff, and never awaited termination — the result code completed while export threads were still running.
  • It also called HttpClient.close(), which blocks until all operations complete, on the caller's thread.
  • Now calls shutdownNow(), awaits termination (5s, warning on timeout), and closes the client on a daemon thread before completing the result.
  • This mirrors the sibling HttpSender implementations OkHttpGrpcSender (the reference named in the issue) and OkHttpHttpSender. OkHttp's cancelAll() / evictAll() have no java.net.http equivalent; shutdownNow() plus close() cover that role.
  • Close failures still propagate through the result code; unmanaged executors still return immediately.

Testing done

  • Added JdkHttpSenderTest#shutdown_managedExecutor_awaitsTermination (executor terminated once the result succeeds) and #shutdown_nonManagedExecutor_doesNotShutDownExecutor (completes immediately, injected executor left running).
  • Existing testShutdown / testShutdownException cover close-exception propagation on the new async path.
  • ./gradlew :exporters:sender:jdk:check — 13 tests passed.
  • No apidiff or CHANGELOG.md entry: the japicmp-excluded internal package only.

@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.77778% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.59%. Comparing base (b86f040) to head (c861861).

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

❌ Your patch check has failed because the patch coverage (77.77%) 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    #8627      +/-   ##
============================================
- Coverage     91.60%   91.59%   -0.01%     
- Complexity    10343    10346       +3     
============================================
  Files          1013     1013              
  Lines         27352    27368      +16     
  Branches       3215     3216       +1     
============================================
+ Hits          25057    25069      +12     
- Misses         1567     1570       +3     
- Partials        728      729       +1     

☔ 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.

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