DefaultSleeper.close can strand pending sleepAsync futures
维护者通常 1 天内回复
评估
调研方向
从 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
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
openai/openai-java 的其他 Issue
-
HttpRequest.url() logs spaces in path segments as literal plus signs可能已有人在做 @sylvesterkaczmarek 于 52 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
openai/openai-java#886 · 2 条评论 ·
维护者通常 1 天内回复
-
Make diarized transcription duration and task optional可能已有人在做 @wskr00 于 83 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 68/100
openai/openai-java#802 · 2 条评论 · 3 个 reaction ·
维护者通常 1 天内回复
-
AsyncStreamResponse can hang when the subscriber executor rejects work可能已有人在做 @sylvesterkaczmarek 于 35 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 74/100
openai/openai-java#973 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 35/100
openai/openai-java#956 ·
维护者通常 1 天内回复
-
Async internal plumbing bypasses both `dispatcherExecutorService` and `streamHandlerExecutor`, forcing a hop through `ForkJoinPool.commonPool()`可能已有人在做 @sylvesterkaczmarek 于 30 天前认领。 未关闭
难度 5/5 一周以上 新手友好度 35/100
openai/openai-java#952 ·
维护者通常 1 天内回复
查看 openai/openai-java 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 66/100
partiql/partiql-lang-kotlin#1972 ·
-
afk-ok area:data-quality importer size:S
难度 2/5 1-3 小时 新手友好度 82/100
enorm-labs/event-junkie#3027 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
-
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 68/100
libre-tube/LibreTube#8854 ·
维护者通常 1 天内回复