openai / openai/openai-java

RetryingHttpClient.close skips sleeper cleanup when delegate close fails

Open Beginner friendly
#890 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Kotlin
Stars
1.5k
Forks
264
Avg merge
9h 46m
Merged PRs (30d)
96

Description

Description

RetryingHttpClient owns both its delegate HttpClient and Sleeper, but closes them sequentially:

override fun close() {
    httpClient.close()
    sleeper.close()
}

If httpClient.close() throws, sleeper.close() is never attempted.

This can leak sleeper-owned resources. The default sleeper owns a Timer, and custom sleepers may own executors or other lifecycle state.

The repository already uses a failure-preserving close pattern in AuthenticatingHttpClient: always attempt both owned cleanups, propagate the first failure, and attach a distinct second failure as suppressed.

Expected behavior

RetryingHttpClient.close() should always attempt to close both owned resources.

If both fail, the delegate failure should remain primary and the sleeper failure should be attached as suppressed. If only the sleeper fails, that failure should propagate normally.

Regression coverage

  • delegate close failure still closes the sleeper;
  • both close failures preserve the delegate failure and suppress the sleeper failure;
  • sleeper-only failure propagates;
  • normal close closes both resources.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating RetryingHttpClient and its close() implementation, then compare it with the failure-preserving close pattern in AuthenticatingHttpClient. Add regression coverage for delegate-only failure, both failures, sleeper-only failure, and normal cleanup; done means both resources are always attempted and failures are propagated as specified.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.