FR: AutoClosable AttachedContext
- Vorherrschende Sprache
- Java
- Sterne
- 12.1k
- Forks
- 4k
- Ø Merge
- 2 T. 17 Std.
- Gemergte PRs (30 T.)
- 37
Beschreibung
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.
Beitragsleitfaden
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- java
- Bereich
- api, backend
- Issue-Typ
- Feature
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 35/100