From f3337f28cee14f1d98249c13edd14ec8d4bc699d Mon Sep 17 00:00:00 2001 From: Kurt Alfred Kluever Date: Fri, 27 Aug 2021 17:11:06 -0400 Subject: [PATCH] stub: Add @InlineMe to deprecated gRPC APIs (#8457) Read more @ https://errorprone.info/docs/inlineme --- stub/BUILD.bazel | 1 + stub/build.gradle | 1 + stub/src/main/java/io/grpc/stub/MetadataUtils.java | 10 ++++++++++ 3 files changed, 12 insertions(+) diff --git a/stub/BUILD.bazel b/stub/BUILD.bazel index 181ffe0485..c65b01a23d 100644 --- a/stub/BUILD.bazel +++ b/stub/BUILD.bazel @@ -8,6 +8,7 @@ java_library( "//api", "//context", "@com_google_code_findbugs_jsr305//jar", + "@com_google_errorprone_error_prone_annotations//jar", "@com_google_guava_guava//jar", "@com_google_j2objc_j2objc_annotations//jar", ], diff --git a/stub/build.gradle b/stub/build.gradle index 4076460377..2b5a6a4edb 100644 --- a/stub/build.gradle +++ b/stub/build.gradle @@ -10,6 +10,7 @@ description = "gRPC: Stub" dependencies { api project(':grpc-api'), libraries.guava + implementation libraries.errorprone testImplementation libraries.truth, project(':grpc-testing') signature "org.codehaus.mojo.signature:java17:1.0@signature" diff --git a/stub/src/main/java/io/grpc/stub/MetadataUtils.java b/stub/src/main/java/io/grpc/stub/MetadataUtils.java index 94dfb8e56e..5395ba9b5e 100644 --- a/stub/src/main/java/io/grpc/stub/MetadataUtils.java +++ b/stub/src/main/java/io/grpc/stub/MetadataUtils.java @@ -18,6 +18,7 @@ package io.grpc.stub; import static com.google.common.base.Preconditions.checkNotNull; +import com.google.errorprone.annotations.InlineMe; import io.grpc.CallOptions; import io.grpc.Channel; import io.grpc.ClientCall; @@ -47,6 +48,10 @@ public final class MetadataUtils { */ @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1789") @Deprecated + @InlineMe( + replacement = + "stub.withInterceptors(MetadataUtils.newAttachHeadersInterceptor(extraHeaders))", + imports = "io.grpc.stub.MetadataUtils") public static > T attachHeaders(T stub, Metadata extraHeaders) { return stub.withInterceptors(newAttachHeadersInterceptor(extraHeaders)); } @@ -104,6 +109,11 @@ public final class MetadataUtils { */ @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1789") @Deprecated + @InlineMe( + replacement = + "stub.withInterceptors(MetadataUtils.newCaptureMetadataInterceptor(headersCapture," + + " trailersCapture))", + imports = "io.grpc.stub.MetadataUtils") public static > T captureMetadata( T stub, AtomicReference headersCapture,