Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

DefaultSleeper.close can strand pending sleepAsync futures

未关闭
#889 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@sylvesterkaczmarek 已经在做这个了。

开始于 2026年8月18日。

  • #892 来自 @sylvesterkaczmarek —— 未关闭

评估

难度
3/5
预计耗时
1-2 天
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
冷清
技术栈
java, kotlin
领域
api

调研方向

从 DefaultSleeper.sleepAsync() 和 close() 开始,然后检查 RetryingHttpClient 如何根据 sleep future 组成下一次请求。添加回归测试,验证待处理的 future 会在关闭时完成,已完成的 sleep 不会留下待处理的跟踪,重复调用 close() 是安全的,并且关闭后调用 sleepAsync() 会返回一个已完成的 future。

由索引模型根据 Issue 内容生成。

描述

Description

DefaultSleeper.sleepAsync() schedules a TimerTask that completes a CompletableFuture, while close() only cancels the underlying Timer:

override fun close() = timer.cancel()

Timer.cancel() discards scheduled tasks that have not yet run. Their associated futures are not completed or cancelled.

A caller waiting on one of those futures can therefore wait forever after the sleeper is closed. In the SDK this can happen while an async retry is in backoff: RetryingHttpClient composes the next request from sleeper.sleepAsync(backoffDuration), so closing the client during that delay can strand the request future.

Expected behavior

Closing DefaultSleeper should deterministically settle every pending async sleep future rather than abandoning it.

Suggested fix

Track pending timer tasks/futures. On close, cancel the timer and complete or cancel each pending future. Tasks that run normally should remove themselves from the pending set.

The close path should be idempotent, and a post-close sleepAsync() call should return an already-failed/cancelled future rather than throwing synchronously from Timer.schedule.

Regression coverage

  • close settles a long pending sleepAsync() future promptly;
  • normally completed sleeps are removed from pending tracking;
  • repeated close is safe;
  • sleepAsync() after close returns a settled exceptional/cancelled future instead of throwing synchronously.
主要语言
Kotlin
星标
1.5k
派生
266
平均合并
8 小时 18 分钟
30 天内合并 PR
142

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

openai/openai-java 的其他 Issue

查看 openai/openai-java 的全部 Issue

相似的 Issue

更多 Kotlin Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。