what-the-bank/sources/io/grpc/util/TransmitStatusRuntimeExcept...

328 lines
14 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package io.grpc.util;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.SettableFuture;
import io.grpc.Attributes;
import io.grpc.ForwardingServerCall;
import io.grpc.ForwardingServerCallListener;
import io.grpc.Metadata;
import io.grpc.ServerCall;
import io.grpc.ServerCallHandler;
import io.grpc.ServerInterceptor;
import io.grpc.Status;
import io.grpc.StatusRuntimeException;
import io.grpc.internal.SerializingExecutor;
import java.util.concurrent.ExecutionException;
/* loaded from: classes6.dex */
public final class TransmitStatusRuntimeExceptionInterceptor implements ServerInterceptor {
private TransmitStatusRuntimeExceptionInterceptor() {
}
public static ServerInterceptor instance() {
return new TransmitStatusRuntimeExceptionInterceptor();
}
@Override // io.grpc.ServerInterceptor
public final <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(ServerCall<ReqT, RespT> serverCall, Metadata metadata, ServerCallHandler<ReqT, RespT> serverCallHandler) {
SerializingServerCall serializingServerCall = new SerializingServerCall(serverCall);
return new ForwardingServerCallListener.SimpleForwardingServerCallListener<ReqT>(this, serverCallHandler.startCall(serializingServerCall, metadata), serializingServerCall) { // from class: io.grpc.util.TransmitStatusRuntimeExceptionInterceptor.1
final TransmitStatusRuntimeExceptionInterceptor this$0;
final ServerCall val$serverCall;
{
this.this$0 = this;
this.val$serverCall = serializingServerCall;
}
@Override // io.grpc.ForwardingServerCallListener, io.grpc.ServerCall.Listener
public void onMessage(ReqT reqt) {
try {
super.onMessage(reqt);
} catch (StatusRuntimeException e) {
closeWithException(e);
}
}
@Override // io.grpc.ForwardingServerCallListener.SimpleForwardingServerCallListener, io.grpc.ForwardingServerCallListener, io.grpc.PartialForwardingServerCallListener, io.grpc.ServerCall.Listener
public void onHalfClose() {
try {
super.onHalfClose();
} catch (StatusRuntimeException e) {
closeWithException(e);
}
}
@Override // io.grpc.ForwardingServerCallListener.SimpleForwardingServerCallListener, io.grpc.ForwardingServerCallListener, io.grpc.PartialForwardingServerCallListener, io.grpc.ServerCall.Listener
public void onCancel() {
try {
super.onCancel();
} catch (StatusRuntimeException e) {
closeWithException(e);
}
}
@Override // io.grpc.ForwardingServerCallListener.SimpleForwardingServerCallListener, io.grpc.ForwardingServerCallListener, io.grpc.PartialForwardingServerCallListener, io.grpc.ServerCall.Listener
public void onComplete() {
try {
super.onComplete();
} catch (StatusRuntimeException e) {
closeWithException(e);
}
}
@Override // io.grpc.ForwardingServerCallListener.SimpleForwardingServerCallListener, io.grpc.ForwardingServerCallListener, io.grpc.PartialForwardingServerCallListener, io.grpc.ServerCall.Listener
public void onReady() {
try {
super.onReady();
} catch (StatusRuntimeException e) {
closeWithException(e);
}
}
private void closeWithException(StatusRuntimeException statusRuntimeException) {
Metadata trailers = statusRuntimeException.getTrailers();
if (trailers == null) {
trailers = new Metadata();
}
this.val$serverCall.close(statusRuntimeException.getStatus(), trailers);
}
};
}
/* loaded from: classes6.dex */
static class SerializingServerCall<ReqT, RespT> extends ForwardingServerCall.SimpleForwardingServerCall<ReqT, RespT> {
private static final String ERROR_MSG = "Encountered error during serialized access";
private boolean closeCalled;
private final SerializingExecutor serializingExecutor;
SerializingServerCall(ServerCall<ReqT, RespT> serverCall) {
super(serverCall);
this.serializingExecutor = new SerializingExecutor(MoreExecutors.directExecutor());
this.closeCalled = false;
}
@Override // io.grpc.ForwardingServerCall, io.grpc.ServerCall
public void sendMessage(RespT respt) {
this.serializingExecutor.execute(new Runnable(this, respt) { // from class: io.grpc.util.TransmitStatusRuntimeExceptionInterceptor.SerializingServerCall.1
final SerializingServerCall this$0;
final Object val$message;
{
this.this$0 = this;
this.val$message = respt;
}
@Override // java.lang.Runnable
public void run() {
SerializingServerCall.super.sendMessage(this.val$message);
}
});
}
@Override // io.grpc.ForwardingServerCall.SimpleForwardingServerCall, io.grpc.ForwardingServerCall, io.grpc.PartialForwardingServerCall, io.grpc.ServerCall
public void request(int i) {
this.serializingExecutor.execute(new Runnable(this, i) { // from class: io.grpc.util.TransmitStatusRuntimeExceptionInterceptor.SerializingServerCall.2
final SerializingServerCall this$0;
final int val$numMessages;
{
this.this$0 = this;
this.val$numMessages = i;
}
@Override // java.lang.Runnable
public void run() {
SerializingServerCall.super.request(this.val$numMessages);
}
});
}
@Override // io.grpc.ForwardingServerCall.SimpleForwardingServerCall, io.grpc.ForwardingServerCall, io.grpc.PartialForwardingServerCall, io.grpc.ServerCall
public void sendHeaders(Metadata metadata) {
this.serializingExecutor.execute(new Runnable(this, metadata) { // from class: io.grpc.util.TransmitStatusRuntimeExceptionInterceptor.SerializingServerCall.3
final SerializingServerCall this$0;
final Metadata val$headers;
{
this.this$0 = this;
this.val$headers = metadata;
}
@Override // java.lang.Runnable
public void run() {
SerializingServerCall.super.sendHeaders(this.val$headers);
}
});
}
@Override // io.grpc.ForwardingServerCall.SimpleForwardingServerCall, io.grpc.ForwardingServerCall, io.grpc.PartialForwardingServerCall, io.grpc.ServerCall
public void close(Status status, Metadata metadata) {
this.serializingExecutor.execute(new Runnable(this, status, metadata) { // from class: io.grpc.util.TransmitStatusRuntimeExceptionInterceptor.SerializingServerCall.4
final SerializingServerCall this$0;
final Status val$status;
final Metadata val$trailers;
{
this.this$0 = this;
this.val$status = status;
this.val$trailers = metadata;
}
@Override // java.lang.Runnable
public void run() {
if (this.this$0.closeCalled) {
return;
}
this.this$0.closeCalled = true;
SerializingServerCall.super.close(this.val$status, this.val$trailers);
}
});
}
/* JADX WARN: Multi-variable type inference failed */
@Override // io.grpc.ForwardingServerCall.SimpleForwardingServerCall, io.grpc.ForwardingServerCall, io.grpc.PartialForwardingServerCall, io.grpc.ServerCall
public boolean isReady() {
SettableFuture create = SettableFuture.create();
this.serializingExecutor.execute(new Runnable(this, create) { // from class: io.grpc.util.TransmitStatusRuntimeExceptionInterceptor.SerializingServerCall.5
final SerializingServerCall this$0;
final SettableFuture val$retVal;
{
this.this$0 = this;
this.val$retVal = create;
}
@Override // java.lang.Runnable
public void run() {
this.val$retVal.set(Boolean.valueOf(SerializingServerCall.super.isReady()));
}
});
try {
return ((Boolean) create.get()).booleanValue();
} catch (InterruptedException e) {
throw new RuntimeException(ERROR_MSG, e);
} catch (ExecutionException e2) {
throw new RuntimeException(ERROR_MSG, e2);
}
}
/* JADX WARN: Multi-variable type inference failed */
@Override // io.grpc.ForwardingServerCall.SimpleForwardingServerCall, io.grpc.ForwardingServerCall, io.grpc.PartialForwardingServerCall, io.grpc.ServerCall
public boolean isCancelled() {
SettableFuture create = SettableFuture.create();
this.serializingExecutor.execute(new Runnable(this, create) { // from class: io.grpc.util.TransmitStatusRuntimeExceptionInterceptor.SerializingServerCall.6
final SerializingServerCall this$0;
final SettableFuture val$retVal;
{
this.this$0 = this;
this.val$retVal = create;
}
@Override // java.lang.Runnable
public void run() {
this.val$retVal.set(Boolean.valueOf(SerializingServerCall.super.isCancelled()));
}
});
try {
return ((Boolean) create.get()).booleanValue();
} catch (InterruptedException e) {
throw new RuntimeException(ERROR_MSG, e);
} catch (ExecutionException e2) {
throw new RuntimeException(ERROR_MSG, e2);
}
}
@Override // io.grpc.ForwardingServerCall.SimpleForwardingServerCall, io.grpc.ForwardingServerCall, io.grpc.PartialForwardingServerCall, io.grpc.ServerCall
public void setMessageCompression(boolean z) {
this.serializingExecutor.execute(new Runnable(this, z) { // from class: io.grpc.util.TransmitStatusRuntimeExceptionInterceptor.SerializingServerCall.7
final SerializingServerCall this$0;
final boolean val$enabled;
{
this.this$0 = this;
this.val$enabled = z;
}
@Override // java.lang.Runnable
public void run() {
SerializingServerCall.super.setMessageCompression(this.val$enabled);
}
});
}
@Override // io.grpc.ForwardingServerCall.SimpleForwardingServerCall, io.grpc.ForwardingServerCall, io.grpc.PartialForwardingServerCall, io.grpc.ServerCall
public void setCompression(String str) {
this.serializingExecutor.execute(new Runnable(this, str) { // from class: io.grpc.util.TransmitStatusRuntimeExceptionInterceptor.SerializingServerCall.8
final SerializingServerCall this$0;
final String val$compressor;
{
this.this$0 = this;
this.val$compressor = str;
}
@Override // java.lang.Runnable
public void run() {
SerializingServerCall.super.setCompression(this.val$compressor);
}
});
}
/* JADX WARN: Multi-variable type inference failed */
@Override // io.grpc.ForwardingServerCall.SimpleForwardingServerCall, io.grpc.ForwardingServerCall, io.grpc.PartialForwardingServerCall, io.grpc.ServerCall
public Attributes getAttributes() {
SettableFuture create = SettableFuture.create();
this.serializingExecutor.execute(new Runnable(this, create) { // from class: io.grpc.util.TransmitStatusRuntimeExceptionInterceptor.SerializingServerCall.9
final SerializingServerCall this$0;
final SettableFuture val$retVal;
{
this.this$0 = this;
this.val$retVal = create;
}
@Override // java.lang.Runnable
public void run() {
this.val$retVal.set(SerializingServerCall.super.getAttributes());
}
});
try {
return (Attributes) create.get();
} catch (InterruptedException e) {
throw new RuntimeException(ERROR_MSG, e);
} catch (ExecutionException e2) {
throw new RuntimeException(ERROR_MSG, e2);
}
}
/* JADX WARN: Multi-variable type inference failed */
@Override // io.grpc.ForwardingServerCall.SimpleForwardingServerCall, io.grpc.ForwardingServerCall, io.grpc.PartialForwardingServerCall, io.grpc.ServerCall
public String getAuthority() {
SettableFuture create = SettableFuture.create();
this.serializingExecutor.execute(new Runnable(this, create) { // from class: io.grpc.util.TransmitStatusRuntimeExceptionInterceptor.SerializingServerCall.10
final SerializingServerCall this$0;
final SettableFuture val$retVal;
{
this.this$0 = this;
this.val$retVal = create;
}
@Override // java.lang.Runnable
public void run() {
this.val$retVal.set(SerializingServerCall.super.getAuthority());
}
});
try {
return (String) create.get();
} catch (InterruptedException e) {
throw new RuntimeException(ERROR_MSG, e);
} catch (ExecutionException e2) {
throw new RuntimeException(ERROR_MSG, e2);
}
}
}
}