导航菜单

页面标题

页面副标题

SpeedCash v6.5.1482 - TransmitStatusRuntimeExceptionInterceptor.java 源代码

正在查看: SpeedCash v6.5.1482 应用的 TransmitStatusRuntimeExceptionInterceptor.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


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.ExperimentalApi;
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;
import javax.annotation.Nullable;

@ExperimentalApi("https://github.com/grpc/grpc-java/issues/2189")
public final class TransmitStatusRuntimeExceptionInterceptor implements ServerInterceptor {

    public class a<ReqT> extends ForwardingServerCallListener.SimpleForwardingServerCallListener<ReqT> {
        public final ServerCall b;

        public a(ServerCall.Listener listener, ServerCall serverCall) {
            super(listener);
            this.b = serverCall;
        }

        public final void a(StatusRuntimeException statusRuntimeException) {
            Metadata trailers = statusRuntimeException.getTrailers();
            if (trailers == null) {
                trailers = new Metadata();
            }
            this.b.close(statusRuntimeException.getStatus(), trailers);
        }

        public void onCancel() {
            try {
                super.onCancel();
            } catch (StatusRuntimeException e) {
                a(e);
            }
        }

        public void onComplete() {
            try {
                super.onComplete();
            } catch (StatusRuntimeException e) {
                a(e);
            }
        }

        public void onHalfClose() {
            try {
                super.onHalfClose();
            } catch (StatusRuntimeException e) {
                a(e);
            }
        }

        public void onMessage(ReqT reqt) {
            try {
                super/*io.grpc.ForwardingServerCallListener*/.onMessage(reqt);
            } catch (StatusRuntimeException e) {
                a(e);
            }
        }

        public void onReady() {
            try {
                super.onReady();
            } catch (StatusRuntimeException e) {
                a(e);
            }
        }
    }

    public static class b<ReqT, RespT> extends ForwardingServerCall.SimpleForwardingServerCall<ReqT, RespT> {
        public final SerializingExecutor b;
        public boolean c;

        public class a implements Runnable {
            public final SettableFuture a;

            public a(SettableFuture settableFuture) {
                this.a = settableFuture;
            }

            @Override
            public void run() {
                this.a.set(b.super.getAuthority());
            }
        }

        public class RunnableC0021b implements Runnable {
            public final Object a;

            public RunnableC0021b(Object obj) {
                this.a = obj;
            }

            @Override
            public void run() {
                super/*io.grpc.ForwardingServerCall*/.sendMessage(this.a);
            }
        }

        public class c implements Runnable {
            public final int a;

            public c(int i) {
                this.a = i;
            }

            @Override
            public void run() {
                b.super.request(this.a);
            }
        }

        public class d implements Runnable {
            public final Metadata a;

            public d(Metadata metadata) {
                this.a = metadata;
            }

            @Override
            public void run() {
                b.super.sendHeaders(this.a);
            }
        }

        public class e implements Runnable {
            public final Status a;
            public final Metadata b;

            public e(Status status, Metadata metadata) {
                this.a = status;
                this.b = metadata;
            }

            @Override
            public void run() {
                if (b.this.c) {
                    return;
                }
                b.this.c = true;
                b.super.close(this.a, this.b);
            }
        }

        public class f implements Runnable {
            public final SettableFuture a;

            public f(SettableFuture settableFuture) {
                this.a = settableFuture;
            }

            @Override
            public void run() {
                this.a.set(Boolean.valueOf(b.super.isReady()));
            }
        }

        public class g implements Runnable {
            public final SettableFuture a;

            public g(SettableFuture settableFuture) {
                this.a = settableFuture;
            }

            @Override
            public void run() {
                this.a.set(Boolean.valueOf(b.super.isCancelled()));
            }
        }

        public class h implements Runnable {
            public final boolean a;

            public h(boolean z) {
                this.a = z;
            }

            @Override
            public void run() {
                b.super.setMessageCompression(this.a);
            }
        }

        public class i implements Runnable {
            public final String a;

            public i(String str) {
                this.a = str;
            }

            @Override
            public void run() {
                b.super.setCompression(this.a);
            }
        }

        public class j implements Runnable {
            public final SettableFuture a;

            public j(SettableFuture settableFuture) {
                this.a = settableFuture;
            }

            @Override
            public void run() {
                this.a.set(b.super.getAttributes());
            }
        }

        public b(ServerCall<ReqT, RespT> serverCall) {
            super(serverCall);
            this.b = new SerializingExecutor(MoreExecutors.directExecutor());
            this.c = false;
        }

        public void close(Status status, Metadata metadata) {
            this.b.execute(new e(status, metadata));
        }

        public Attributes getAttributes() {
            SettableFuture create = SettableFuture.create();
            this.b.execute(new j(create));
            try {
                return (Attributes) create.get();
            } catch (InterruptedException e2) {
                throw new RuntimeException("Encountered error during serialized access", e2);
            } catch (ExecutionException e3) {
                throw new RuntimeException("Encountered error during serialized access", e3);
            }
        }

        @Nullable
        public String getAuthority() {
            SettableFuture create = SettableFuture.create();
            this.b.execute(new a(create));
            try {
                return (String) create.get();
            } catch (InterruptedException e2) {
                throw new RuntimeException("Encountered error during serialized access", e2);
            } catch (ExecutionException e3) {
                throw new RuntimeException("Encountered error during serialized access", e3);
            }
        }

        public boolean isCancelled() {
            SettableFuture create = SettableFuture.create();
            this.b.execute(new g(create));
            try {
                return ((Boolean) create.get()).booleanValue();
            } catch (InterruptedException e2) {
                throw new RuntimeException("Encountered error during serialized access", e2);
            } catch (ExecutionException e3) {
                throw new RuntimeException("Encountered error during serialized access", e3);
            }
        }

        public boolean isReady() {
            SettableFuture create = SettableFuture.create();
            this.b.execute(new f(create));
            try {
                return ((Boolean) create.get()).booleanValue();
            } catch (InterruptedException e2) {
                throw new RuntimeException("Encountered error during serialized access", e2);
            } catch (ExecutionException e3) {
                throw new RuntimeException("Encountered error during serialized access", e3);
            }
        }

        public void request(int i2) {
            this.b.execute(new c(i2));
        }

        public void sendHeaders(Metadata metadata) {
            this.b.execute(new d(metadata));
        }

        public void sendMessage(RespT respt) {
            this.b.execute(new RunnableC0021b(respt));
        }

        public void setCompression(String str) {
            this.b.execute(new i(str));
        }

        public void setMessageCompression(boolean z) {
            this.b.execute(new h(z));
        }
    }

    public static ServerInterceptor instance() {
        return new TransmitStatusRuntimeExceptionInterceptor();
    }

    public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(ServerCall<ReqT, RespT> serverCall, Metadata metadata, ServerCallHandler<ReqT, RespT> serverCallHandler) {
        b bVar = new b(serverCall);
        return new a(serverCallHandler.startCall(bVar, metadata), bVar);
    }
}