stub: Add @InlineMe to deprecated gRPC APIs (#8457)

Read more @ https://errorprone.info/docs/inlineme
This commit is contained in:
Kurt Alfred Kluever 2021-08-27 17:11:06 -04:00 committed by GitHub
parent 0f6380b470
commit f3337f28ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 0 deletions

View File

@ -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",
],

View File

@ -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"

View File

@ -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 extends AbstractStub<T>> 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 extends AbstractStub<T>> T captureMetadata(
T stub,
AtomicReference<Metadata> headersCapture,