Skip to content

Commit

Permalink
stub: Mark Stub-based MetadataUtils methods deprecated
Browse files Browse the repository at this point in the history
We don't want other APIs to copy the stub-based API to attach the
interceptor. The API has a shorter name, but isn't actually all that
easier to use and isn't fluent like using the interceptor API.

These are _very_ old methods, so we won't be quick to delete them. Seems
we should have them deprecated at least a year or two; they are easy to
maintain in the mean time.

See API Review notes in #1789
  • Loading branch information
ejona86 committed Aug 6, 2021
1 parent 57bd087 commit 0fef093
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions stub/src/main/java/io/grpc/stub/MetadataUtils.java
Expand Up @@ -43,8 +43,10 @@ private MetadataUtils() {}
* @param stub to bind the headers to.
* @param extraHeaders the headers to be passed by each call on the returned stub.
* @return an implementation of the stub with {@code extraHeaders} bound to each call.
* @deprecated Replace with {@code stub.withInterceptors(newAttachHeadersInterceptor(...))}
*/
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1789")
@Deprecated
public static <T extends AbstractStub<T>> T attachHeaders(T stub, Metadata extraHeaders) {
return stub.withInterceptors(newAttachHeadersInterceptor(extraHeaders));
}
Expand Down Expand Up @@ -98,8 +100,10 @@ public void start(Listener<RespT> responseListener, Metadata headers) {
* @param trailersCapture to record the last received trailers
* @return an implementation of the stub that allows to access the last received call's
* headers and trailers via {@code headersCapture} and {@code trailersCapture}.
* @deprecated Replace with {@code stub.withInterceptors(newCaptureMetadataInterceptor())}
*/
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1789")
@Deprecated
public static <T extends AbstractStub<T>> T captureMetadata(
T stub,
AtomicReference<Metadata> headersCapture,
Expand Down

0 comments on commit 0fef093

Please sign in to comment.