FR: AutoClosable AttachedContext
- Lingua principale
- Java
- Stelle
- 12.1k
- Fork
- 4k
- Merge medio
- 2g 17h
- PR unite (30g)
- 37
Descrizione
Today, if you want to use [`io.grpc.Context.attach()`](https://grpc.io/grpc-java/javadoc/io/grpc/Context.html#attach--), you have to provide your own `try`/`finally` block. In order to take advantage of try-with-resources, if there were a `AttachedContext` that implemented `java.lang.AutoClosable`, then you could have
try (AttachedContext ac = new AttachedContext(context)) {
…
}
and omit the `finally` block.
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Start with the io.grpc.Context.attach() API described in the issue and inspect how its attached context is currently restored. Define the AttachedContext resource so try-with-resources can replace the caller's try/finally pattern, and verify that closing it restores the previous context.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- java
- Ambito
- api, backend
- Tipo di issue
- Funzionalità
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 35/100