DefaultSleeper.close can strand pending sleepAsync futures
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 72/100
Direzione di ricerca
Inizia da DefaultSleeper.sleepAsync() e close(), quindi esamina come RetryingHttpClient compone la richiesta successiva a partire dal future di sleep. Aggiungi una copertura di regressione che dimostri che i future in sospeso vengono risolti alla chiusura, che gli sleep completati non lasciano tracciamenti in sospeso, che le chiamate ripetute a close() sono sicure e che sleepAsync() restituisce un future risolto dopo la chiusura.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Kotlin
- Stelle
- 1.5k
- Fork
- 264
- Merge medio
- 13h 31m
- PR unite (30g)
- 89
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di openai/openai-java
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
openai/openai-java#890 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
openai/openai-java#886 · 2 commenti ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
openai/openai-java#802 · 2 commenti · 3 reazioni ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
openai/openai-java#755 · 1 commento ·
-
bug sdk
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
openai/openai-java#652 · 2 commenti ·
Tutte le issue di openai/openai-java
Issue simili
-
Remove custom segment colors Apertaenhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
libre-tube/LibreTube#8803 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Telegram !!! Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
Xposed-Modules-Repo/com.fuck.iab#24 · 3 commenti · 1 reazione ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
SimonHalvdansson/Harmonic-HN#361 ·