DefaultSleeper.close can strand pending sleepAsync futures
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 72/100
Hướng nghiên cứu
Bắt đầu từ DefaultSleeper.sleepAsync() và close(), sau đó kiểm tra cách RetryingHttpClient tạo request tiếp theo từ sleep future. Thêm kiểm thử hồi quy cho thấy các future đang chờ được hoàn tất khi đóng, các sleep đã hoàn tất không để lại việc theo dõi đang chờ, việc gọi close() lặp lại là an toàn và sleepAsync() trả về một future đã hoàn tất sau khi đóng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Kotlin
- Star
- 1.5k
- Fork
- 264
- Merge trung bình
- 13 giờ 51 phút
- Pull request đã merge (30 ngày)
- 113
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của openai/openai-java
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
openai/openai-java#886 · 2 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
openai/openai-java#802 · 2 bình luận · 3 reaction ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
openai/openai-java#755 · 1 bình luận ·
-
bug sdk
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
openai/openai-java#652 · 2 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 74/100
openai/openai-java#973 ·
Tất cả issue của openai/openai-java
Issue tương tự
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Richie97/track-history#325 ·
-
bug CLI documentation reliability
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
KW-related Type:bug UI / UX
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
RevenueCat/purchases-android#4299 · 1 bình luận ·
-
[Bug] 统计页面无法重置token和汇率 Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
AAswordman/Operit#1265 · 3 bình luận ·