grpc / grpc/grpc-java

FR: AutoClosable AttachedContext

Open
#4,329 2 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Java
Stars
12.1k
Forks
4k
Avg merge
2d 17h
Merged PRs (30d)
37

Description

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.