正在查看: Chaupal v3.2 应用的 e.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Chaupal v3.2 应用的 e.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package io.grpc.okhttp;
import com.google.common.base.o;
import com.google.common.base.q;
import de.a;
import io.grpc.HttpConnectProxiedSocketAddress;
import io.grpc.MethodDescriptor;
import io.grpc.SecurityLevel;
import io.grpc.Status;
import io.grpc.StatusException;
import io.grpc.c0;
import io.grpc.internal.ClientStreamListener;
import io.grpc.internal.GrpcUtil;
import io.grpc.internal.KeepAliveManager;
import io.grpc.internal.b1;
import io.grpc.internal.e2;
import io.grpc.internal.o0;
import io.grpc.internal.p;
import io.grpc.internal.p0;
import io.grpc.internal.s;
import io.grpc.internal.t1;
import io.grpc.internal.v1;
import io.grpc.internal.y1;
import io.grpc.okhttp.OkHttpFrameLogger;
import io.grpc.okhttp.b;
import io.grpc.okhttp.d;
import io.grpc.okhttp.internal.framed.ErrorCode;
import io.grpc.okhttp.internal.framed.HeadersMode;
import io.grpc.y;
import java.io.EOFException;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.URI;
import java.util.Collections;
import java.util.Deque;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor;
import java.util.concurrent.ScheduledExecutorService;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.net.SocketFactory;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import okhttp3.HttpUrl;
import okhttp3.internal.http2.Settings;
import okhttp3.internal.ws.RealWebSocket;
import okio.ByteString;
import okio.k0;
import okio.l0;
import okio.x;
import rb.c;
import rb.d;
class e implements s, b.a {
private static final Map<ErrorCode, Status> X = Q();
private static final Logger Y = Logger.getLogger(e.class.getName());
private static final io.grpc.okhttp.d[] Z = new io.grpc.okhttp.d[0];
private final SocketFactory A;
private SSLSocketFactory B;
private HostnameVerifier C;
private Socket D;
private final io.grpc.okhttp.internal.a G;
private de.b H;
private ScheduledExecutorService I;
private KeepAliveManager J;
private boolean K;
private long L;
private long M;
private boolean N;
private final Runnable O;
private final int P;
private final boolean Q;
private final e2 R;
private y.b T;
final HttpConnectProxiedSocketAddress U;
Runnable V;
com.google.common.util.concurrent.e<Void> W;
private final InetSocketAddress a;
private final String b;
private final String c;
private final q<o> e;
private final int f;
private b1.a g;
private de.a h;
private OkHttpFrameLogger i;
private io.grpc.okhttp.b j;
private l k;
private final c0 m;
private final Executor p;
private final t1 q;
private final int r;
private int s;
private f t;
private io.grpc.a u;
private Status v;
private boolean f50w;
private o0 x;
private boolean y;
private boolean z;
private final Random d = new Random();
private final Object l = new Object();
private final Map<Integer, io.grpc.okhttp.d> o = new HashMap();
private int E = 0;
private final Deque<io.grpc.okhttp.d> F = new LinkedList();
private final p0<io.grpc.okhttp.d> S = new a();
private int n = 3;
class a extends p0<io.grpc.okhttp.d> {
a() {
}
@Override
protected void b() {
e.this.g.c(true);
}
@Override
protected void c() {
e.this.g.c(false);
}
}
class b implements e2.c {
b() {
}
}
class c implements Runnable {
c() {
}
@Override
public void run() {
Runnable runnable = e.this.V;
if (runnable != null) {
runnable.run();
}
e eVar = e.this;
eVar.t = eVar.new f(eVar.h, e.this.i);
e.this.p.execute(e.this.t);
synchronized (e.this.l) {
e.this.E = Integer.MAX_VALUE;
e.this.n0();
}
e.this.W.A((Object) null);
}
}
class d implements Runnable {
final CountDownLatch a;
final io.grpc.okhttp.a c;
final de.h d;
class a implements k0 {
a() {
}
@Override
public void close() {
}
@Override
public long read(okio.e eVar, long j) {
return -1L;
}
@Override
public l0 timeout() {
return l0.NONE;
}
}
d(CountDownLatch countDownLatch, io.grpc.okhttp.a aVar, de.h hVar) {
this.a = countDownLatch;
this.c = aVar;
this.d = hVar;
}
@Override
public void run() {
e eVar;
f fVar;
Socket S;
try {
this.a.await();
} catch (InterruptedException unused) {
Thread.currentThread().interrupt();
}
okio.g c = x.c(new a());
SSLSession sSLSession = null;
try {
try {
e eVar2 = e.this;
HttpConnectProxiedSocketAddress httpConnectProxiedSocketAddress = eVar2.U;
if (httpConnectProxiedSocketAddress == null) {
S = eVar2.A.createSocket(e.this.a.getAddress(), e.this.a.getPort());
} else {
if (!(httpConnectProxiedSocketAddress.getProxyAddress() instanceof InetSocketAddress)) {
throw Status.t.r("Unsupported SocketAddress implementation " + e.this.U.getProxyAddress().getClass()).c();
}
e eVar3 = e.this;
S = eVar3.S(eVar3.U.getTargetAddress(), (InetSocketAddress) e.this.U.getProxyAddress(), e.this.U.getUsername(), e.this.U.getPassword());
}
Socket socket = S;
Socket socket2 = socket;
if (e.this.B != null) {
SSLSocket b = i.b(e.this.B, e.this.C, socket, e.this.X(), e.this.Y(), e.this.G);
sSLSession = b.getSession();
socket2 = b;
}
socket2.setTcpNoDelay(true);
okio.g c2 = x.c(x.k(socket2));
this.c.j(x.g(socket2), socket2);
e eVar4 = e.this;
eVar4.u = eVar4.u.d().d(io.grpc.x.a, socket2.getRemoteSocketAddress()).d(io.grpc.x.b, socket2.getLocalSocketAddress()).d(io.grpc.x.c, sSLSession).d(io.grpc.internal.l0.a, sSLSession == null ? SecurityLevel.NONE : SecurityLevel.PRIVACY_AND_INTEGRITY).a();
e eVar5 = e.this;
eVar5.t = new f(eVar5, this.d.a(c2, true));
synchronized (e.this.l) {
e.this.D = (Socket) com.google.common.base.l.p(socket2, "socket");
if (sSLSession != null) {
e.this.T = new y.b(new y.c(sSLSession));
}
}
} catch (StatusException e) {
e.this.m0(0, ErrorCode.INTERNAL_ERROR, e.getStatus());
eVar = e.this;
fVar = new f(eVar, this.d.a(c, true));
eVar.t = fVar;
} catch (Exception e2) {
e.this.a(e2);
eVar = e.this;
fVar = new f(eVar, this.d.a(c, true));
eVar.t = fVar;
}
} catch (Throwable th) {
e eVar6 = e.this;
eVar6.t = new f(eVar6, this.d.a(c, true));
throw th;
}
}
}
class RunnableC0020e implements Runnable {
RunnableC0020e() {
}
@Override
public void run() {
e.this.p.execute(e.this.t);
synchronized (e.this.l) {
e.this.E = Integer.MAX_VALUE;
e.this.n0();
}
}
}
class f implements a.InterfaceC0002a, Runnable {
private final OkHttpFrameLogger a;
de.a c;
boolean d;
f(e eVar, de.a aVar) {
this(aVar, new OkHttpFrameLogger(Level.FINE, (Class<?>) e.class));
}
private int a(List<de.c> list) {
long j = 0;
for (int i = 0; i < list.size(); i++) {
de.c cVar = list.get(i);
j += cVar.a.size() + 32 + cVar.b.size();
}
return (int) Math.min(j, 2147483647L);
}
@Override
public void ackSettings() {
}
@Override
public void d(int i, ErrorCode errorCode) {
this.a.h(OkHttpFrameLogger.Direction.INBOUND, i, errorCode);
Status f = e.r0(errorCode).f("Rst Stream");
boolean z = f.n() == Status.Code.CANCELLED || f.n() == Status.Code.DEADLINE_EXCEEDED;
synchronized (e.this.l) {
io.grpc.okhttp.d dVar = (io.grpc.okhttp.d) e.this.o.get(Integer.valueOf(i));
if (dVar != null) {
ge.c.c("OkHttpClientTransport$ClientFrameHandler.rstStream", dVar.t().f0());
e.this.U(i, f, errorCode == ErrorCode.REFUSED_STREAM ? ClientStreamListener.RpcProgress.REFUSED : ClientStreamListener.RpcProgress.PROCESSED, z, null, null);
}
}
}
@Override
public void data(boolean z, int i, okio.g gVar, int i2) throws IOException {
this.a.b(OkHttpFrameLogger.Direction.INBOUND, i, gVar.y(), i2, z);
io.grpc.okhttp.d a0 = e.this.a0(i);
if (a0 != null) {
long j = i2;
gVar.t0(j);
okio.e eVar = new okio.e();
eVar.write(gVar.y(), j);
ge.c.c("OkHttpClientTransport$ClientFrameHandler.data", a0.t().f0());
synchronized (e.this.l) {
a0.t().g0(eVar, z);
}
} else {
if (!e.this.e0(i)) {
e.this.h0(ErrorCode.PROTOCOL_ERROR, "Received data for unknown stream: " + i);
return;
}
synchronized (e.this.l) {
e.this.j.d(i, ErrorCode.INVALID_STREAM);
}
gVar.skip(i2);
}
e.B(e.this, i2);
if (e.this.s >= e.this.f * 0.5f) {
synchronized (e.this.l) {
e.this.j.windowUpdate(0, e.this.s);
}
e.this.s = 0;
}
}
@Override
public void e(int i, ErrorCode errorCode, ByteString byteString) {
this.a.c(OkHttpFrameLogger.Direction.INBOUND, i, errorCode, byteString);
if (errorCode == ErrorCode.ENHANCE_YOUR_CALM) {
String utf8 = byteString.utf8();
e.Y.log(Level.WARNING, String.format("%s: Received GOAWAY with ENHANCE_YOUR_CALM. Debug data: %s", this, utf8));
if ("too_many_pings".equals(utf8)) {
e.this.O.run();
}
}
Status f = GrpcUtil.Http2Error.statusForCode(errorCode.httpCode).f("Received Goaway");
if (byteString.size() > 0) {
f = f.f(byteString.utf8());
}
e.this.m0(i, null, f);
}
@Override
public void f(boolean z, de.g gVar) {
boolean z2;
this.a.i(OkHttpFrameLogger.Direction.INBOUND, gVar);
synchronized (e.this.l) {
if (h.b(gVar, 4)) {
e.this.E = h.a(gVar, 4);
}
if (h.b(gVar, 7)) {
z2 = e.this.k.e(h.a(gVar, 7));
} else {
z2 = false;
}
if (this.d) {
e.this.g.b();
this.d = false;
}
e.this.j.r(gVar);
if (z2) {
e.this.k.h();
}
e.this.n0();
}
}
@Override
public void g(boolean z, boolean z2, int i, int i2, List<de.c> list, HeadersMode headersMode) {
Status status;
int a;
this.a.d(OkHttpFrameLogger.Direction.INBOUND, i, list, z2);
boolean z3 = true;
if (e.this.P == Integer.MAX_VALUE || (a = a(list)) <= e.this.P) {
status = null;
} else {
Status status2 = Status.o;
Object[] objArr = new Object[3];
objArr[0] = z2 ? "trailer" : "header";
objArr[1] = Integer.valueOf(e.this.P);
objArr[2] = Integer.valueOf(a);
status = status2.r(String.format("Response %s metadata larger than %d: %d", objArr));
}
synchronized (e.this.l) {
io.grpc.okhttp.d dVar = (io.grpc.okhttp.d) e.this.o.get(Integer.valueOf(i));
if (dVar == null) {
if (e.this.e0(i)) {
e.this.j.d(i, ErrorCode.INVALID_STREAM);
}
} else if (status == null) {
ge.c.c("OkHttpClientTransport$ClientFrameHandler.headers", dVar.t().f0());
dVar.t().h0(list, z2);
} else {
if (!z2) {
e.this.j.d(i, ErrorCode.CANCEL);
}
dVar.t().N(status, false, new io.grpc.o0());
}
z3 = false;
}
if (z3) {
e.this.h0(ErrorCode.PROTOCOL_ERROR, "Received header for unknown stream: " + i);
}
}
@Override
public void ping(boolean z, int i, int i2) {
o0 o0Var;
long j = (i << 32) | (i2 & 4294967295L);
this.a.e(OkHttpFrameLogger.Direction.INBOUND, j);
if (!z) {
synchronized (e.this.l) {
e.this.j.ping(true, i, i2);
}
return;
}
synchronized (e.this.l) {
o0Var = null;
if (e.this.x == null) {
e.Y.warning("Received unexpected ping ack. No ping outstanding");
} else if (e.this.x.h() == j) {
o0 o0Var2 = e.this.x;
e.this.x = null;
o0Var = o0Var2;
} else {
e.Y.log(Level.WARNING, String.format("Received unexpected ping ack. Expecting %d, got %d", Long.valueOf(e.this.x.h()), Long.valueOf(j)));
}
}
if (o0Var != null) {
o0Var.d();
}
}
@Override
public void priority(int i, int i2, int i3, boolean z) {
}
@Override
public void pushPromise(int i, int i2, List<de.c> list) throws IOException {
this.a.g(OkHttpFrameLogger.Direction.INBOUND, i, i2, list);
synchronized (e.this.l) {
e.this.j.d(i, ErrorCode.PROTOCOL_ERROR);
}
}
@Override
public void run() {
Status status;
String name = Thread.currentThread().getName();
Thread.currentThread().setName("OkHttpClientTransport");
while (this.c.q(this)) {
try {
if (e.this.J != null) {
e.this.J.l();
}
} catch (Throwable th) {
try {
e.this.m0(0, ErrorCode.PROTOCOL_ERROR, Status.t.r("error in frame handler").q(th));
try {
this.c.close();
} catch (IOException e) {
e = e;
e.Y.log(Level.INFO, "Exception closing frame reader", (Throwable) e);
e.this.g.d();
Thread.currentThread().setName(name);
}
} catch (Throwable th2) {
try {
this.c.close();
} catch (IOException e2) {
e.Y.log(Level.INFO, "Exception closing frame reader", (Throwable) e2);
}
e.this.g.d();
Thread.currentThread().setName(name);
throw th2;
}
}
}
synchronized (e.this.l) {
status = e.this.v;
}
if (status == null) {
status = Status.u.r("End of stream or IOException");
}
e.this.m0(0, ErrorCode.INTERNAL_ERROR, status);
try {
this.c.close();
} catch (IOException e3) {
e = e3;
e.Y.log(Level.INFO, "Exception closing frame reader", (Throwable) e);
e.this.g.d();
Thread.currentThread().setName(name);
}
e.this.g.d();
Thread.currentThread().setName(name);
}
@Override
public void windowUpdate(int i, long j) {
this.a.k(OkHttpFrameLogger.Direction.INBOUND, i, j);
if (j == 0) {
if (i == 0) {
e.this.h0(ErrorCode.PROTOCOL_ERROR, "Received 0 flow control window increment.");
return;
} else {
e.this.U(i, Status.t.r("Received 0 flow control window increment."), ClientStreamListener.RpcProgress.PROCESSED, false, ErrorCode.PROTOCOL_ERROR, null);
return;
}
}
boolean z = false;
synchronized (e.this.l) {
if (i == 0) {
e.this.k.g(null, (int) j);
return;
}
io.grpc.okhttp.d dVar = (io.grpc.okhttp.d) e.this.o.get(Integer.valueOf(i));
if (dVar != null) {
e.this.k.g(dVar, (int) j);
} else if (!e.this.e0(i)) {
z = true;
}
if (z) {
e.this.h0(ErrorCode.PROTOCOL_ERROR, "Received window_update for unknown stream: " + i);
}
}
}
f(de.a aVar, OkHttpFrameLogger okHttpFrameLogger) {
this.d = true;
this.c = aVar;
this.a = okHttpFrameLogger;
}
}
e(InetSocketAddress inetSocketAddress, String str, String str2, io.grpc.a aVar, Executor executor, SocketFactory socketFactory, SSLSocketFactory sSLSocketFactory, HostnameVerifier hostnameVerifier, io.grpc.okhttp.internal.a aVar2, int i, int i2, HttpConnectProxiedSocketAddress httpConnectProxiedSocketAddress, Runnable runnable, int i3, e2 e2Var, boolean z) {
this.a = (InetSocketAddress) com.google.common.base.l.p(inetSocketAddress, "address");
this.b = str;
this.r = i;
this.f = i2;
this.p = (Executor) com.google.common.base.l.p(executor, "executor");
this.q = new t1(executor);
this.A = socketFactory == null ? SocketFactory.getDefault() : socketFactory;
this.B = sSLSocketFactory;
this.C = hostnameVerifier;
this.G = (io.grpc.okhttp.internal.a) com.google.common.base.l.p(aVar2, "connectionSpec");
this.e = GrpcUtil.v;
this.c = GrpcUtil.g("okhttp", str2);
this.U = httpConnectProxiedSocketAddress;
this.O = (Runnable) com.google.common.base.l.p(runnable, "tooManyPingsRunnable");
this.P = i3;
this.R = (e2) com.google.common.base.l.o(e2Var);
this.m = c0.a(getClass(), inetSocketAddress.toString());
this.u = io.grpc.a.c().d(io.grpc.internal.l0.b, aVar).a();
this.Q = z;
b0();
}
static int B(e eVar, int i) {
int i2 = eVar.s + i;
eVar.s = i2;
return i2;
}
private static Map<ErrorCode, Status> Q() {
EnumMap enumMap = new EnumMap(ErrorCode.class);
ErrorCode errorCode = ErrorCode.NO_ERROR;
Status status = Status.t;
enumMap.put((EnumMap) errorCode, (ErrorCode) status.r("No error: A GRPC status of OK should have been sent"));
enumMap.put((EnumMap) ErrorCode.PROTOCOL_ERROR, (ErrorCode) status.r("Protocol error"));
enumMap.put((EnumMap) ErrorCode.INTERNAL_ERROR, (ErrorCode) status.r("Internal error"));
enumMap.put((EnumMap) ErrorCode.FLOW_CONTROL_ERROR, (ErrorCode) status.r("Flow control error"));
enumMap.put((EnumMap) ErrorCode.STREAM_CLOSED, (ErrorCode) status.r("Stream closed"));
enumMap.put((EnumMap) ErrorCode.FRAME_TOO_LARGE, (ErrorCode) status.r("Frame too large"));
enumMap.put((EnumMap) ErrorCode.REFUSED_STREAM, (ErrorCode) Status.u.r("Refused stream"));
enumMap.put((EnumMap) ErrorCode.CANCEL, (ErrorCode) Status.g.r("Cancelled"));
enumMap.put((EnumMap) ErrorCode.COMPRESSION_ERROR, (ErrorCode) status.r("Compression error"));
enumMap.put((EnumMap) ErrorCode.CONNECT_ERROR, (ErrorCode) status.r("Connect error"));
enumMap.put((EnumMap) ErrorCode.ENHANCE_YOUR_CALM, (ErrorCode) Status.o.r("Enhance your calm"));
enumMap.put((EnumMap) ErrorCode.INADEQUATE_SECURITY, (ErrorCode) Status.m.r("Inadequate security"));
return Collections.unmodifiableMap(enumMap);
}
private rb.d R(InetSocketAddress inetSocketAddress, String str, String str2) {
rb.c a2 = new c.b().k("https").h(inetSocketAddress.getHostName()).j(inetSocketAddress.getPort()).a();
d.b g = new d.b().h(a2).g("Host", a2.c() + ":" + a2.j()).g("User-Agent", this.c);
if (str != null && str2 != null) {
g.g("Proxy-Authorization", rb.a.a(str, str2));
}
return g.f();
}
public Socket S(InetSocketAddress inetSocketAddress, InetSocketAddress inetSocketAddress2, String str, String str2) throws StatusException {
try {
Socket createSocket = inetSocketAddress2.getAddress() != null ? this.A.createSocket(inetSocketAddress2.getAddress(), inetSocketAddress2.getPort()) : this.A.createSocket(inetSocketAddress2.getHostName(), inetSocketAddress2.getPort());
createSocket.setTcpNoDelay(true);
k0 k = x.k(createSocket);
okio.f b2 = x.b(x.g(createSocket));
rb.d R = R(inetSocketAddress, str, str2);
rb.c b3 = R.b();
b2.a0(String.format("CONNECT %s:%d HTTP/1.1", b3.c(), Integer.valueOf(b3.j()))).a0("\r\n");
int b4 = R.a().b();
for (int i = 0; i < b4; i++) {
b2.a0(R.a().a(i)).a0(": ").a0(R.a().c(i)).a0("\r\n");
}
b2.a0("\r\n");
b2.flush();
sb.a a2 = sb.a.a(i0(k));
while (!i0(k).equals(HttpUrl.FRAGMENT_ENCODE_SET)) {
}
int i2 = a2.b;
if (i2 >= 200 && i2 < 300) {
return createSocket;
}
okio.e eVar = new okio.e();
try {
createSocket.shutdownOutput();
k.read(eVar, RealWebSocket.DEFAULT_MINIMUM_DEFLATE_SIZE);
} catch (IOException e) {
eVar.a0("Unable to read body: " + e.toString());
}
try {
createSocket.close();
} catch (IOException unused) {
}
throw Status.u.r(String.format("Response returned from proxy was not successful (expected 2xx, got %d %s). Response body:\n%s", Integer.valueOf(a2.b), a2.c, eVar.D0())).c();
} catch (IOException e2) {
throw Status.u.r("Failed trying to connect with proxy").q(e2).c();
}
}
private Throwable Z() {
synchronized (this.l) {
Status status = this.v;
if (status != null) {
return status.c();
}
return Status.u.r("Connection closed").c();
}
}
private void b0() {
synchronized (this.l) {
this.R.g(new b());
}
}
private boolean c0() {
return this.a == null;
}
private void f0(io.grpc.okhttp.d dVar) {
if (this.z && this.F.isEmpty() && this.o.isEmpty()) {
this.z = false;
KeepAliveManager keepAliveManager = this.J;
if (keepAliveManager != null) {
keepAliveManager.n();
}
}
if (dVar.x()) {
this.S.e(dVar, false);
}
}
public void h0(ErrorCode errorCode, String str) {
m0(0, errorCode, r0(errorCode).f(str));
}
private static String i0(k0 k0Var) throws IOException {
okio.e eVar = new okio.e();
while (k0Var.read(eVar, 1L) != -1) {
if (eVar.k(eVar.M0() - 1) == 10) {
return eVar.i0();
}
}
throw new EOFException("\\n not found: " + eVar.T0().hex());
}
private void l0(io.grpc.okhttp.d dVar) {
if (!this.z) {
this.z = true;
KeepAliveManager keepAliveManager = this.J;
if (keepAliveManager != null) {
keepAliveManager.m();
}
}
if (dVar.x()) {
this.S.e(dVar, true);
}
}
public void m0(int i, ErrorCode errorCode, Status status) {
synchronized (this.l) {
if (this.v == null) {
this.v = status;
this.g.a(status);
}
if (errorCode != null && !this.f50w) {
this.f50w = true;
this.j.n1(0, errorCode, new byte[0]);
}
Iterator<Map.Entry<Integer, io.grpc.okhttp.d>> it = this.o.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<Integer, io.grpc.okhttp.d> next = it.next();
if (next.getKey().intValue() > i) {
it.remove();
next.getValue().t().M(status, ClientStreamListener.RpcProgress.REFUSED, false, new io.grpc.o0());
f0(next.getValue());
}
}
for (io.grpc.okhttp.d dVar : this.F) {
dVar.t().M(status, ClientStreamListener.RpcProgress.REFUSED, true, new io.grpc.o0());
f0(dVar);
}
this.F.clear();
p0();
}
}
public boolean n0() {
boolean z = false;
while (!this.F.isEmpty() && this.o.size() < this.E) {
o0(this.F.poll());
z = true;
}
return z;
}
private void o0(io.grpc.okhttp.d dVar) {
com.google.common.base.l.v(dVar.P() == -1, "StreamId already assigned");
this.o.put(Integer.valueOf(this.n), dVar);
l0(dVar);
dVar.t().d0(this.n);
if ((dVar.O() != MethodDescriptor.MethodType.UNARY && dVar.O() != MethodDescriptor.MethodType.SERVER_STREAMING) || dVar.S()) {
this.j.flush();
}
int i = this.n;
if (i < 2147483645) {
this.n = i + 2;
} else {
this.n = Integer.MAX_VALUE;
m0(Integer.MAX_VALUE, ErrorCode.NO_ERROR, Status.u.r("Stream ids exhausted"));
}
}
private void p0() {
if (this.v == null || !this.o.isEmpty() || !this.F.isEmpty() || this.y) {
return;
}
this.y = true;
KeepAliveManager keepAliveManager = this.J;
if (keepAliveManager != null) {
keepAliveManager.p();
this.I = (ScheduledExecutorService) v1.f(GrpcUtil.u, this.I);
}
o0 o0Var = this.x;
if (o0Var != null) {
o0Var.f(Z());
this.x = null;
}
if (!this.f50w) {
this.f50w = true;
this.j.n1(0, ErrorCode.NO_ERROR, new byte[0]);
}
this.j.close();
}
static Status r0(ErrorCode errorCode) {
Status status = X.get(errorCode);
if (status != null) {
return status;
}
return Status.h.r("Unknown http2 error code: " + errorCode.httpCode);
}
void T(boolean z, long j, long j2, boolean z2) {
this.K = z;
this.L = j;
this.M = j2;
this.N = z2;
}
void U(int i, Status status, ClientStreamListener.RpcProgress rpcProgress, boolean z, ErrorCode errorCode, io.grpc.o0 o0Var) {
synchronized (this.l) {
io.grpc.okhttp.d remove = this.o.remove(Integer.valueOf(i));
if (remove != null) {
if (errorCode != null) {
this.j.d(i, ErrorCode.CANCEL);
}
if (status != null) {
d.b t = remove.t();
if (o0Var == null) {
o0Var = new io.grpc.o0();
}
t.M(status, rpcProgress, z, o0Var);
}
if (!n0()) {
p0();
f0(remove);
}
}
}
}
io.grpc.okhttp.d[] V() {
io.grpc.okhttp.d[] dVarArr;
synchronized (this.l) {
dVarArr = (io.grpc.okhttp.d[]) this.o.values().toArray(Z);
}
return dVarArr;
}
public io.grpc.a W() {
return this.u;
}
String X() {
URI b2 = GrpcUtil.b(this.b);
return b2.getHost() != null ? b2.getHost() : this.b;
}
int Y() {
URI b2 = GrpcUtil.b(this.b);
return b2.getPort() != -1 ? b2.getPort() : this.a.getPort();
}
@Override
public void a(Throwable th) {
com.google.common.base.l.p(th, "failureCause");
m0(0, ErrorCode.INTERNAL_ERROR, Status.u.q(th));
}
io.grpc.okhttp.d a0(int i) {
io.grpc.okhttp.d dVar;
synchronized (this.l) {
dVar = this.o.get(Integer.valueOf(i));
}
return dVar;
}
@Override
public void b(Status status) {
f(status);
synchronized (this.l) {
Iterator<Map.Entry<Integer, io.grpc.okhttp.d>> it = this.o.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<Integer, io.grpc.okhttp.d> next = it.next();
it.remove();
next.getValue().t().N(status, false, new io.grpc.o0());
f0(next.getValue());
}
for (io.grpc.okhttp.d dVar : this.F) {
dVar.t().N(status, true, new io.grpc.o0());
f0(dVar);
}
this.F.clear();
p0();
}
}
@Override
public c0 c() {
return this.m;
}
@Override
public void d(p.a aVar, Executor executor) {
long nextLong;
synchronized (this.l) {
boolean z = true;
com.google.common.base.l.u(this.j != null);
if (this.y) {
o0.g(aVar, executor, Z());
return;
}
o0 o0Var = this.x;
if (o0Var != null) {
nextLong = 0;
z = false;
} else {
nextLong = this.d.nextLong();
o oVar = (o) this.e.get();
oVar.g();
o0 o0Var2 = new o0(nextLong, oVar);
this.x = o0Var2;
this.R.b();
o0Var = o0Var2;
}
if (z) {
this.j.ping(false, (int) (nextLong >>> 32), (int) nextLong);
}
o0Var.a(aVar, executor);
}
}
boolean d0() {
return this.B == null;
}
boolean e0(int i) {
boolean z;
synchronized (this.l) {
z = true;
if (i >= this.n || (i & 1) != 1) {
z = false;
}
}
return z;
}
@Override
public void f(Status status) {
synchronized (this.l) {
if (this.v != null) {
return;
}
this.v = status;
this.g.a(status);
p0();
}
}
@Override
public Runnable g(b1.a aVar) {
this.g = (b1.a) com.google.common.base.l.p(aVar, "listener");
if (this.K) {
this.I = (ScheduledExecutorService) v1.d(GrpcUtil.u);
KeepAliveManager keepAliveManager = new KeepAliveManager(new KeepAliveManager.c(this), this.I, this.L, this.M, this.N);
this.J = keepAliveManager;
keepAliveManager.o();
}
if (c0()) {
synchronized (this.l) {
io.grpc.okhttp.b bVar = new io.grpc.okhttp.b(this, this.H, this.i);
this.j = bVar;
this.k = new l(this, bVar);
}
this.q.execute(new c());
return null;
}
io.grpc.okhttp.a k = io.grpc.okhttp.a.k(this.q, this);
de.e eVar = new de.e();
de.b b2 = eVar.b(x.b(k), true);
synchronized (this.l) {
io.grpc.okhttp.b bVar2 = new io.grpc.okhttp.b(this, b2);
this.j = bVar2;
this.k = new l(this, bVar2);
}
CountDownLatch countDownLatch = new CountDownLatch(1);
this.q.execute(new d(countDownLatch, k, eVar));
try {
k0();
countDownLatch.countDown();
this.q.execute(new RunnableC0020e());
return null;
} catch (Throwable th) {
countDownLatch.countDown();
throw th;
}
}
@Override
public io.grpc.okhttp.d e(MethodDescriptor<?, ?> methodDescriptor, io.grpc.o0 o0Var, io.grpc.c cVar, io.grpc.j[] jVarArr) {
com.google.common.base.l.p(methodDescriptor, "method");
com.google.common.base.l.p(o0Var, "headers");
y1 h = y1.h(jVarArr, W(), o0Var);
synchronized (this.l) {
try {
try {
return new io.grpc.okhttp.d(methodDescriptor, o0Var, this.j, this, this.k, this.l, this.r, this.f, this.b, this.c, h, this.R, cVar, this.Q);
} catch (Throwable th) {
th = th;
throw th;
}
} catch (Throwable th2) {
th = th2;
}
}
}
void j0(io.grpc.okhttp.d dVar) {
this.F.remove(dVar);
f0(dVar);
}
void k0() {
synchronized (this.l) {
this.j.connectionPreface();
de.g gVar = new de.g();
h.c(gVar, 7, this.f);
this.j.p(gVar);
if (this.f > 65535) {
this.j.windowUpdate(0, r1 - Settings.DEFAULT_INITIAL_WINDOW_SIZE);
}
}
}
void q0(io.grpc.okhttp.d dVar) {
if (this.v != null) {
dVar.t().M(this.v, ClientStreamListener.RpcProgress.REFUSED, true, new io.grpc.o0());
} else if (this.o.size() < this.E) {
o0(dVar);
} else {
this.F.add(dVar);
l0(dVar);
}
}
public String toString() {
return com.google.common.base.g.c(this).c("logId", this.m.d()).d("address", this.a).toString();
}
}