what-the-bank/sources/io/grpc/stub/MetadataUtils.java

128 lines
6.4 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package io.grpc.stub;
import com.google.common.base.Preconditions;
import io.grpc.CallOptions;
import io.grpc.Channel;
import io.grpc.ClientCall;
import io.grpc.ClientInterceptor;
import io.grpc.ForwardingClientCall;
import io.grpc.ForwardingClientCallListener;
import io.grpc.Metadata;
import io.grpc.MethodDescriptor;
import io.grpc.Status;
import java.util.concurrent.atomic.AtomicReference;
/* loaded from: classes6.dex */
public final class MetadataUtils {
private MetadataUtils() {
}
@Deprecated
public static <T extends AbstractStub<T>> T attachHeaders(T t, Metadata metadata) {
return (T) t.withInterceptors(newAttachHeadersInterceptor(metadata));
}
public static ClientInterceptor newAttachHeadersInterceptor(Metadata metadata) {
return new HeaderAttachingClientInterceptor(metadata);
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes6.dex */
public static final class HeaderAttachingClientInterceptor implements ClientInterceptor {
private final Metadata extraHeaders;
HeaderAttachingClientInterceptor(Metadata metadata) {
this.extraHeaders = (Metadata) Preconditions.checkNotNull(metadata, "extraHeaders");
}
@Override // io.grpc.ClientInterceptor
public final <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall(MethodDescriptor<ReqT, RespT> methodDescriptor, CallOptions callOptions, Channel channel) {
return new HeaderAttachingClientCall(this, channel.newCall(methodDescriptor, callOptions));
}
/* loaded from: classes6.dex */
final class HeaderAttachingClientCall<ReqT, RespT> extends ForwardingClientCall.SimpleForwardingClientCall<ReqT, RespT> {
final HeaderAttachingClientInterceptor this$0;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
HeaderAttachingClientCall(HeaderAttachingClientInterceptor headerAttachingClientInterceptor, ClientCall<ReqT, RespT> clientCall) {
super(clientCall);
this.this$0 = headerAttachingClientInterceptor;
}
@Override // io.grpc.ForwardingClientCall, io.grpc.ClientCall
public final void start(ClientCall.Listener<RespT> listener, Metadata metadata) {
metadata.merge(this.this$0.extraHeaders);
super.start(listener, metadata);
}
}
}
@Deprecated
public static <T extends AbstractStub<T>> T captureMetadata(T t, AtomicReference<Metadata> atomicReference, AtomicReference<Metadata> atomicReference2) {
return (T) t.withInterceptors(newCaptureMetadataInterceptor(atomicReference, atomicReference2));
}
public static ClientInterceptor newCaptureMetadataInterceptor(AtomicReference<Metadata> atomicReference, AtomicReference<Metadata> atomicReference2) {
return new MetadataCapturingClientInterceptor(atomicReference, atomicReference2);
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes6.dex */
public static final class MetadataCapturingClientInterceptor implements ClientInterceptor {
final AtomicReference<Metadata> headersCapture;
final AtomicReference<Metadata> trailersCapture;
MetadataCapturingClientInterceptor(AtomicReference<Metadata> atomicReference, AtomicReference<Metadata> atomicReference2) {
this.headersCapture = (AtomicReference) Preconditions.checkNotNull(atomicReference, "headersCapture");
this.trailersCapture = (AtomicReference) Preconditions.checkNotNull(atomicReference2, "trailersCapture");
}
@Override // io.grpc.ClientInterceptor
public final <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall(MethodDescriptor<ReqT, RespT> methodDescriptor, CallOptions callOptions, Channel channel) {
return new MetadataCapturingClientCall(this, channel.newCall(methodDescriptor, callOptions));
}
/* loaded from: classes6.dex */
final class MetadataCapturingClientCall<ReqT, RespT> extends ForwardingClientCall.SimpleForwardingClientCall<ReqT, RespT> {
final MetadataCapturingClientInterceptor this$0;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
MetadataCapturingClientCall(MetadataCapturingClientInterceptor metadataCapturingClientInterceptor, ClientCall<ReqT, RespT> clientCall) {
super(clientCall);
this.this$0 = metadataCapturingClientInterceptor;
}
@Override // io.grpc.ForwardingClientCall, io.grpc.ClientCall
public final void start(ClientCall.Listener<RespT> listener, Metadata metadata) {
this.this$0.headersCapture.set(null);
this.this$0.trailersCapture.set(null);
super.start(new MetadataCapturingClientCallListener(this, listener), metadata);
}
/* loaded from: classes6.dex */
final class MetadataCapturingClientCallListener extends ForwardingClientCallListener.SimpleForwardingClientCallListener<RespT> {
final MetadataCapturingClientCall this$1;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
MetadataCapturingClientCallListener(MetadataCapturingClientCall metadataCapturingClientCall, ClientCall.Listener<RespT> listener) {
super(listener);
this.this$1 = metadataCapturingClientCall;
}
@Override // io.grpc.ForwardingClientCallListener.SimpleForwardingClientCallListener, io.grpc.ForwardingClientCallListener, io.grpc.PartialForwardingClientCallListener, io.grpc.ClientCall.Listener
public final void onHeaders(Metadata metadata) {
this.this$1.this$0.headersCapture.set(metadata);
super.onHeaders(metadata);
}
@Override // io.grpc.ForwardingClientCallListener.SimpleForwardingClientCallListener, io.grpc.ForwardingClientCallListener, io.grpc.PartialForwardingClientCallListener, io.grpc.ClientCall.Listener
public final void onClose(Status status, Metadata metadata) {
this.this$1.this$0.trailersCapture.set(metadata);
super.onClose(status, metadata);
}
}
}
}
}