what-the-bank/sources/io/grpc/okhttp/OkHttpClientTransport.java

1270 lines
60 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package io.grpc.okhttp;
import com.google.android.gms.common.internal.ServiceSpecificExtraArgs;
import com.google.android.libraries.places.api.model.PlaceTypes;
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import com.google.common.base.Stopwatch;
import com.google.common.base.Supplier;
import com.google.common.net.HttpHeaders;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;
import io.flutter.embedding.android.KeyboardMap;
import io.grpc.Attributes;
import io.grpc.CallOptions;
import io.grpc.ClientStreamTracer;
import io.grpc.Grpc;
import io.grpc.HttpConnectProxiedSocketAddress;
import io.grpc.InternalChannelz;
import io.grpc.InternalLogId;
import io.grpc.Metadata;
import io.grpc.MethodDescriptor;
import io.grpc.SecurityLevel;
import io.grpc.Status;
import io.grpc.StatusException;
import io.grpc.internal.ClientStream;
import io.grpc.internal.ClientStreamListener;
import io.grpc.internal.ClientTransport;
import io.grpc.internal.ConnectionClientTransport;
import io.grpc.internal.GrpcAttributes;
import io.grpc.internal.GrpcUtil;
import io.grpc.internal.Http2Ping;
import io.grpc.internal.InUseStateAggregator;
import io.grpc.internal.KeepAliveManager;
import io.grpc.internal.ManagedClientTransport;
import io.grpc.internal.SerializingExecutor;
import io.grpc.internal.SharedResourceHolder;
import io.grpc.internal.StatsTraceContext;
import io.grpc.internal.TransportTracer;
import io.grpc.okhttp.ExceptionHandlingFrameWriter;
import io.grpc.okhttp.OkHttpClientStream;
import io.grpc.okhttp.OkHttpFrameLogger;
import io.grpc.okhttp.internal.ConnectionSpec;
import io.grpc.okhttp.internal.framed.ErrorCode;
import io.grpc.okhttp.internal.framed.FrameReader;
import io.grpc.okhttp.internal.framed.FrameWriter;
import io.grpc.okhttp.internal.framed.Header;
import io.grpc.okhttp.internal.framed.HeadersMode;
import io.grpc.okhttp.internal.framed.Http2;
import io.grpc.okhttp.internal.framed.Settings;
import io.grpc.okhttp.internal.framed.Variant;
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 o.C12991fNd;
import o.C12994fNg;
import o.C12995fNh;
import o.C13115fRJ;
import o.C14957gcv;
import o.C15111ghZ;
import o.C15139giB;
import o.C15155gij;
import o.C15160gio;
import o.InterfaceC15149gid;
import o.gdP;
import o.giD;
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes6.dex */
public class OkHttpClientTransport implements ConnectionClientTransport, ExceptionHandlingFrameWriter.TransportExceptionHandler {
private final InetSocketAddress address;
private Attributes attributes;
private ClientFrameHandler clientFrameHandler;
SettableFuture<Void> connectedFuture;
Runnable connectingCallback;
private final ConnectionSpec connectionSpec;
private int connectionUnacknowledgedBytesRead;
private final String defaultAuthority;
private boolean enableKeepAlive;
private final Executor executor;
private ExceptionHandlingFrameWriter frameWriter;
private boolean goAwaySent;
private Status goAwayStatus;
private boolean hasStream;
private HostnameVerifier hostnameVerifier;
private final InUseStateAggregator<OkHttpClientStream> inUseState;
private final int initialWindowSize;
private KeepAliveManager keepAliveManager;
private long keepAliveTimeNanos;
private long keepAliveTimeoutNanos;
private boolean keepAliveWithoutCalls;
private ManagedClientTransport.Listener listener;
private final Object lock;
private final InternalLogId logId;
private int maxConcurrentStreams;
private final int maxInboundMetadataSize;
private final int maxMessageSize;
private int nextStreamId;
private OutboundFlowController outboundFlow;
private final Deque<OkHttpClientStream> pendingStreams;
private Http2Ping ping;
final HttpConnectProxiedSocketAddress proxiedAddr;
private final Random random;
private ScheduledExecutorService scheduler;
private InternalChannelz.Security securityInfo;
private final SerializingExecutor serializingExecutor;
private Socket socket;
private final SocketFactory socketFactory;
private SSLSocketFactory sslSocketFactory;
private boolean stopped;
private final Supplier<Stopwatch> stopwatchFactory;
private final Map<Integer, OkHttpClientStream> streams;
private OkHttpFrameLogger testFrameLogger;
private FrameReader testFrameReader;
private FrameWriter testFrameWriter;
private final Runnable tooManyPingsRunnable;
private final TransportTracer transportTracer;
private final boolean useGetForSafeMethods;
private final String userAgent;
private static final Map<ErrorCode, Status> ERROR_CODE_TO_STATUS = buildErrorCodeToStatusMap();
private static final Logger log = Logger.getLogger(OkHttpClientTransport.class.getName());
private static final OkHttpClientStream[] EMPTY_STREAM_ARRAY = new OkHttpClientStream[0];
static /* synthetic */ int access$2412(OkHttpClientTransport okHttpClientTransport, int i) {
int i2 = okHttpClientTransport.connectionUnacknowledgedBytesRead + i;
okHttpClientTransport.connectionUnacknowledgedBytesRead = i2;
return i2;
}
@Override // io.grpc.internal.ClientTransport
public /* bridge */ /* synthetic */ ClientStream newStream(MethodDescriptor methodDescriptor, Metadata metadata, CallOptions callOptions, ClientStreamTracer[] clientStreamTracerArr) {
return newStream((MethodDescriptor<?, ?>) methodDescriptor, metadata, callOptions, clientStreamTracerArr);
}
private static Map<ErrorCode, Status> buildErrorCodeToStatusMap() {
EnumMap enumMap = new EnumMap(ErrorCode.class);
enumMap.put((EnumMap) ErrorCode.NO_ERROR, (ErrorCode) Status.INTERNAL.withDescription("No error: A GRPC status of OK should have been sent"));
enumMap.put((EnumMap) ErrorCode.PROTOCOL_ERROR, (ErrorCode) Status.INTERNAL.withDescription("Protocol error"));
enumMap.put((EnumMap) ErrorCode.INTERNAL_ERROR, (ErrorCode) Status.INTERNAL.withDescription("Internal error"));
enumMap.put((EnumMap) ErrorCode.FLOW_CONTROL_ERROR, (ErrorCode) Status.INTERNAL.withDescription("Flow control error"));
enumMap.put((EnumMap) ErrorCode.STREAM_CLOSED, (ErrorCode) Status.INTERNAL.withDescription("Stream closed"));
enumMap.put((EnumMap) ErrorCode.FRAME_TOO_LARGE, (ErrorCode) Status.INTERNAL.withDescription("Frame too large"));
enumMap.put((EnumMap) ErrorCode.REFUSED_STREAM, (ErrorCode) Status.UNAVAILABLE.withDescription("Refused stream"));
enumMap.put((EnumMap) ErrorCode.CANCEL, (ErrorCode) Status.CANCELLED.withDescription("Cancelled"));
enumMap.put((EnumMap) ErrorCode.COMPRESSION_ERROR, (ErrorCode) Status.INTERNAL.withDescription("Compression error"));
enumMap.put((EnumMap) ErrorCode.CONNECT_ERROR, (ErrorCode) Status.INTERNAL.withDescription("Connect error"));
enumMap.put((EnumMap) ErrorCode.ENHANCE_YOUR_CALM, (ErrorCode) Status.RESOURCE_EXHAUSTED.withDescription("Enhance your calm"));
enumMap.put((EnumMap) ErrorCode.INADEQUATE_SECURITY, (ErrorCode) Status.PERMISSION_DENIED.withDescription("Inadequate security"));
return Collections.unmodifiableMap(enumMap);
}
/* JADX INFO: Access modifiers changed from: package-private */
public OkHttpClientTransport(InetSocketAddress inetSocketAddress, String str, String str2, Attributes attributes, Executor executor, SocketFactory socketFactory, SSLSocketFactory sSLSocketFactory, HostnameVerifier hostnameVerifier, ConnectionSpec connectionSpec, int i, int i2, HttpConnectProxiedSocketAddress httpConnectProxiedSocketAddress, Runnable runnable, int i3, TransportTracer transportTracer, boolean z) {
this.random = new Random();
this.lock = new Object();
this.streams = new HashMap();
this.maxConcurrentStreams = 0;
this.pendingStreams = new LinkedList();
this.inUseState = new InUseStateAggregator<OkHttpClientStream>(this) { // from class: io.grpc.okhttp.OkHttpClientTransport.1
final OkHttpClientTransport this$0;
{
this.this$0 = this;
}
@Override // io.grpc.internal.InUseStateAggregator
public void handleInUse() {
this.this$0.listener.transportInUse(true);
}
@Override // io.grpc.internal.InUseStateAggregator
public void handleNotInUse() {
this.this$0.listener.transportInUse(false);
}
};
this.address = (InetSocketAddress) Preconditions.checkNotNull(inetSocketAddress, PlaceTypes.ADDRESS);
this.defaultAuthority = str;
this.maxMessageSize = i;
this.initialWindowSize = i2;
this.executor = (Executor) Preconditions.checkNotNull(executor, "executor");
this.serializingExecutor = new SerializingExecutor(executor);
this.nextStreamId = 3;
this.socketFactory = socketFactory == null ? SocketFactory.getDefault() : socketFactory;
this.sslSocketFactory = sSLSocketFactory;
this.hostnameVerifier = hostnameVerifier;
this.connectionSpec = (ConnectionSpec) Preconditions.checkNotNull(connectionSpec, "connectionSpec");
this.stopwatchFactory = GrpcUtil.STOPWATCH_SUPPLIER;
this.userAgent = GrpcUtil.getGrpcUserAgent("okhttp", str2);
this.proxiedAddr = httpConnectProxiedSocketAddress;
this.tooManyPingsRunnable = (Runnable) Preconditions.checkNotNull(runnable, "tooManyPingsRunnable");
this.maxInboundMetadataSize = i3;
this.transportTracer = (TransportTracer) Preconditions.checkNotNull(transportTracer);
this.logId = InternalLogId.allocate(getClass(), inetSocketAddress.toString());
this.attributes = Attributes.newBuilder().set(GrpcAttributes.ATTR_CLIENT_EAG_ATTRS, attributes).build();
this.useGetForSafeMethods = z;
initTransportTracer();
}
OkHttpClientTransport(String str, Executor executor, FrameReader frameReader, FrameWriter frameWriter, OkHttpFrameLogger okHttpFrameLogger, int i, Socket socket, Supplier<Stopwatch> supplier, Runnable runnable, SettableFuture<Void> settableFuture, int i2, int i3, Runnable runnable2, TransportTracer transportTracer) {
this.random = new Random();
this.lock = new Object();
this.streams = new HashMap();
this.maxConcurrentStreams = 0;
this.pendingStreams = new LinkedList();
this.inUseState = new InUseStateAggregator<OkHttpClientStream>(this) { // from class: io.grpc.okhttp.OkHttpClientTransport.1
final OkHttpClientTransport this$0;
{
this.this$0 = this;
}
@Override // io.grpc.internal.InUseStateAggregator
public void handleInUse() {
this.this$0.listener.transportInUse(true);
}
@Override // io.grpc.internal.InUseStateAggregator
public void handleNotInUse() {
this.this$0.listener.transportInUse(false);
}
};
this.useGetForSafeMethods = false;
this.address = null;
this.maxMessageSize = i2;
this.initialWindowSize = i3;
this.defaultAuthority = "notarealauthority:80";
this.userAgent = GrpcUtil.getGrpcUserAgent("okhttp", str);
this.executor = (Executor) Preconditions.checkNotNull(executor, "executor");
this.serializingExecutor = new SerializingExecutor(executor);
this.socketFactory = SocketFactory.getDefault();
this.testFrameReader = (FrameReader) Preconditions.checkNotNull(frameReader, "frameReader");
this.testFrameWriter = (FrameWriter) Preconditions.checkNotNull(frameWriter, "testFrameWriter");
this.testFrameLogger = (OkHttpFrameLogger) Preconditions.checkNotNull(okHttpFrameLogger, "testFrameLogger");
this.socket = (Socket) Preconditions.checkNotNull(socket, "socket");
this.nextStreamId = i;
this.stopwatchFactory = supplier;
this.connectionSpec = null;
this.connectingCallback = runnable;
this.connectedFuture = (SettableFuture) Preconditions.checkNotNull(settableFuture, "connectedFuture");
this.proxiedAddr = null;
this.tooManyPingsRunnable = (Runnable) Preconditions.checkNotNull(runnable2, "tooManyPingsRunnable");
this.maxInboundMetadataSize = Integer.MAX_VALUE;
this.transportTracer = (TransportTracer) Preconditions.checkNotNull(transportTracer, "transportTracer");
this.logId = InternalLogId.allocate(getClass(), String.valueOf(socket.getInetAddress()));
initTransportTracer();
}
private void initTransportTracer() {
synchronized (this.lock) {
this.transportTracer.setFlowControlWindowReader(new TransportTracer.FlowControlReader(this) { // from class: io.grpc.okhttp.OkHttpClientTransport.2
final OkHttpClientTransport this$0;
{
this.this$0 = this;
}
@Override // io.grpc.internal.TransportTracer.FlowControlReader
public TransportTracer.FlowControlWindows read() {
TransportTracer.FlowControlWindows flowControlWindows;
synchronized (this.this$0.lock) {
flowControlWindows = new TransportTracer.FlowControlWindows(-1L, this.this$0.outboundFlow == null ? -1L : this.this$0.outboundFlow.windowUpdate(null, 0));
}
return flowControlWindows;
}
});
}
}
@Override // io.grpc.internal.ClientTransport
public void ping(ClientTransport.PingCallback pingCallback, Executor executor) {
long nextLong;
synchronized (this.lock) {
boolean z = true;
Preconditions.checkState(this.frameWriter != null);
if (this.stopped) {
Http2Ping.notifyFailed(pingCallback, executor, getPingFailure());
return;
}
Http2Ping http2Ping = this.ping;
if (http2Ping != null) {
nextLong = 0;
z = false;
} else {
nextLong = this.random.nextLong();
Stopwatch stopwatch = this.stopwatchFactory.get();
stopwatch.start();
Http2Ping http2Ping2 = new Http2Ping(nextLong, stopwatch);
this.ping = http2Ping2;
this.transportTracer.reportKeepAliveSent();
http2Ping = http2Ping2;
}
if (z) {
this.frameWriter.ping(false, (int) (nextLong >>> 32), (int) nextLong);
}
http2Ping.addCallback(pingCallback, executor);
}
}
@Override // io.grpc.internal.ClientTransport
public OkHttpClientStream newStream(MethodDescriptor<?, ?> methodDescriptor, Metadata metadata, CallOptions callOptions, ClientStreamTracer[] clientStreamTracerArr) {
Object obj;
Preconditions.checkNotNull(methodDescriptor, "method");
Preconditions.checkNotNull(metadata, "headers");
StatsTraceContext newClientContext = StatsTraceContext.newClientContext(clientStreamTracerArr, getAttributes(), metadata);
Object obj2 = this.lock;
synchronized (obj2) {
try {
obj = obj2;
try {
OkHttpClientStream okHttpClientStream = new OkHttpClientStream(methodDescriptor, metadata, this.frameWriter, this, this.outboundFlow, this.lock, this.maxMessageSize, this.initialWindowSize, this.defaultAuthority, this.userAgent, newClientContext, this.transportTracer, callOptions, this.useGetForSafeMethods);
return okHttpClientStream;
} catch (Throwable th) {
th = th;
throw th;
}
} catch (Throwable th2) {
th = th2;
obj = obj2;
}
}
}
/* JADX INFO: Access modifiers changed from: package-private */
public void streamReadyToStart(OkHttpClientStream okHttpClientStream) {
if (this.goAwayStatus != null) {
okHttpClientStream.transportState().transportReportStatus(this.goAwayStatus, ClientStreamListener.RpcProgress.REFUSED, true, new Metadata());
} else if (this.streams.size() >= this.maxConcurrentStreams) {
this.pendingStreams.add(okHttpClientStream);
setInUse(okHttpClientStream);
} else {
startStream(okHttpClientStream);
}
}
private void startStream(OkHttpClientStream okHttpClientStream) {
Preconditions.checkState(okHttpClientStream.id() == -1, "StreamId already assigned");
this.streams.put(Integer.valueOf(this.nextStreamId), okHttpClientStream);
setInUse(okHttpClientStream);
okHttpClientStream.transportState().start(this.nextStreamId);
if ((okHttpClientStream.getType() != MethodDescriptor.MethodType.UNARY && okHttpClientStream.getType() != MethodDescriptor.MethodType.SERVER_STREAMING) || okHttpClientStream.useGet()) {
this.frameWriter.flush();
}
int i = this.nextStreamId;
if (i < 2147483645) {
this.nextStreamId = i + 2;
} else {
this.nextStreamId = Integer.MAX_VALUE;
startGoAway(Integer.MAX_VALUE, ErrorCode.NO_ERROR, Status.UNAVAILABLE.withDescription("Stream ids exhausted"));
}
}
/* JADX INFO: Access modifiers changed from: private */
public boolean startPendingStreams() {
boolean z = false;
while (!this.pendingStreams.isEmpty() && this.streams.size() < this.maxConcurrentStreams) {
startStream(this.pendingStreams.poll());
z = true;
}
return z;
}
/* JADX INFO: Access modifiers changed from: package-private */
public void removePendingStream(OkHttpClientStream okHttpClientStream) {
this.pendingStreams.remove(okHttpClientStream);
maybeClearInUse(okHttpClientStream);
}
@Override // io.grpc.internal.ManagedClientTransport
public Runnable start(ManagedClientTransport.Listener listener) {
this.listener = (ManagedClientTransport.Listener) Preconditions.checkNotNull(listener, ServiceSpecificExtraArgs.CastExtraArgs.LISTENER);
if (this.enableKeepAlive) {
this.scheduler = (ScheduledExecutorService) SharedResourceHolder.get(GrpcUtil.TIMER_SERVICE);
KeepAliveManager keepAliveManager = new KeepAliveManager(new KeepAliveManager.ClientKeepAlivePinger(this), this.scheduler, this.keepAliveTimeNanos, this.keepAliveTimeoutNanos, this.keepAliveWithoutCalls);
this.keepAliveManager = keepAliveManager;
keepAliveManager.onTransportStarted();
}
if (isForTest()) {
synchronized (this.lock) {
ExceptionHandlingFrameWriter exceptionHandlingFrameWriter = new ExceptionHandlingFrameWriter(this, this.testFrameWriter, this.testFrameLogger);
this.frameWriter = exceptionHandlingFrameWriter;
this.outboundFlow = new OutboundFlowController(this, exceptionHandlingFrameWriter);
}
this.serializingExecutor.execute(new Runnable(this) { // from class: io.grpc.okhttp.OkHttpClientTransport.3
final OkHttpClientTransport this$0;
{
this.this$0 = this;
}
@Override // java.lang.Runnable
public void run() {
if (this.this$0.connectingCallback != null) {
this.this$0.connectingCallback.run();
}
OkHttpClientTransport okHttpClientTransport = this.this$0;
okHttpClientTransport.clientFrameHandler = new ClientFrameHandler(okHttpClientTransport, okHttpClientTransport.testFrameReader, this.this$0.testFrameLogger);
this.this$0.executor.execute(this.this$0.clientFrameHandler);
synchronized (this.this$0.lock) {
this.this$0.maxConcurrentStreams = Integer.MAX_VALUE;
this.this$0.startPendingStreams();
}
this.this$0.connectedFuture.set(null);
}
});
return null;
}
AsyncSink sink = AsyncSink.sink(this.serializingExecutor, this);
Http2 http2 = new Http2();
FrameWriter newWriter = http2.newWriter(C15160gio.c(sink), true);
synchronized (this.lock) {
ExceptionHandlingFrameWriter exceptionHandlingFrameWriter2 = new ExceptionHandlingFrameWriter(this, newWriter);
this.frameWriter = exceptionHandlingFrameWriter2;
this.outboundFlow = new OutboundFlowController(this, exceptionHandlingFrameWriter2);
}
CountDownLatch countDownLatch = new CountDownLatch(1);
this.serializingExecutor.execute(new Runnable(this, countDownLatch, sink, http2) { // from class: io.grpc.okhttp.OkHttpClientTransport.4
final OkHttpClientTransport this$0;
final AsyncSink val$asyncSink;
final CountDownLatch val$latch;
final Variant val$variant;
{
this.this$0 = this;
this.val$latch = countDownLatch;
this.val$asyncSink = sink;
this.val$variant = http2;
}
@Override // java.lang.Runnable
public void run() {
OkHttpClientTransport okHttpClientTransport;
ClientFrameHandler clientFrameHandler;
Socket createHttpProxySocket;
SSLSession sSLSession;
Socket socket;
try {
this.val$latch.await();
} catch (InterruptedException unused) {
Thread.currentThread().interrupt();
}
InterfaceC15149gid c = C15160gio.c(new giD(this) { // from class: io.grpc.okhttp.OkHttpClientTransport.4.1
final AnonymousClass4 this$1;
@Override // o.giD, java.io.Closeable, java.lang.AutoCloseable
public void close() {
}
@Override // o.giD
public long read(C15111ghZ c15111ghZ, long j) {
return -1L;
}
{
this.this$1 = this;
}
@Override // o.giD
public C15139giB timeout() {
return C15139giB.NONE;
}
});
try {
try {
if (this.this$0.proxiedAddr == null) {
createHttpProxySocket = this.this$0.socketFactory.createSocket(this.this$0.address.getAddress(), this.this$0.address.getPort());
} else if (this.this$0.proxiedAddr.getProxyAddress() instanceof InetSocketAddress) {
OkHttpClientTransport okHttpClientTransport2 = this.this$0;
createHttpProxySocket = okHttpClientTransport2.createHttpProxySocket(okHttpClientTransport2.proxiedAddr.getTargetAddress(), (InetSocketAddress) this.this$0.proxiedAddr.getProxyAddress(), this.this$0.proxiedAddr.getUsername(), this.this$0.proxiedAddr.getPassword());
} else {
Status status = Status.INTERNAL;
StringBuilder sb = new StringBuilder("Unsupported SocketAddress implementation ");
sb.append(this.this$0.proxiedAddr.getProxyAddress().getClass());
throw status.withDescription(sb.toString()).asException();
}
Socket socket2 = createHttpProxySocket;
if (this.this$0.sslSocketFactory != null) {
SSLSocket upgrade = OkHttpTlsUpgrader.upgrade(this.this$0.sslSocketFactory, this.this$0.hostnameVerifier, socket2, this.this$0.getOverridenHost(), this.this$0.getOverridenPort(), this.this$0.connectionSpec);
sSLSession = upgrade.getSession();
socket = upgrade;
} else {
sSLSession = null;
socket = socket2;
}
socket.setTcpNoDelay(true);
InterfaceC15149gid c2 = C15160gio.c(C15160gio.e(socket));
this.val$asyncSink.becomeConnected(C15160gio.c(socket), socket);
OkHttpClientTransport okHttpClientTransport3 = this.this$0;
okHttpClientTransport3.attributes = okHttpClientTransport3.attributes.toBuilder().set(Grpc.TRANSPORT_ATTR_REMOTE_ADDR, socket.getRemoteSocketAddress()).set(Grpc.TRANSPORT_ATTR_LOCAL_ADDR, socket.getLocalSocketAddress()).set(Grpc.TRANSPORT_ATTR_SSL_SESSION, sSLSession).set(GrpcAttributes.ATTR_SECURITY_LEVEL, sSLSession == null ? SecurityLevel.NONE : SecurityLevel.PRIVACY_AND_INTEGRITY).build();
OkHttpClientTransport okHttpClientTransport4 = this.this$0;
okHttpClientTransport4.clientFrameHandler = new ClientFrameHandler(okHttpClientTransport4, this.val$variant.newReader(c2, true));
synchronized (this.this$0.lock) {
this.this$0.socket = (Socket) Preconditions.checkNotNull(socket, "socket");
if (sSLSession != null) {
this.this$0.securityInfo = new InternalChannelz.Security(new InternalChannelz.Tls(sSLSession));
}
}
} catch (StatusException e) {
this.this$0.startGoAway(0, ErrorCode.INTERNAL_ERROR, e.getStatus());
okHttpClientTransport = this.this$0;
clientFrameHandler = new ClientFrameHandler(okHttpClientTransport, this.val$variant.newReader(c, true));
okHttpClientTransport.clientFrameHandler = clientFrameHandler;
} catch (Exception e2) {
this.this$0.onException(e2);
okHttpClientTransport = this.this$0;
clientFrameHandler = new ClientFrameHandler(okHttpClientTransport, this.val$variant.newReader(c, true));
okHttpClientTransport.clientFrameHandler = clientFrameHandler;
}
} catch (Throwable th) {
OkHttpClientTransport okHttpClientTransport5 = this.this$0;
okHttpClientTransport5.clientFrameHandler = new ClientFrameHandler(okHttpClientTransport5, this.val$variant.newReader(c, true));
throw th;
}
}
});
try {
sendConnectionPrefaceAndSettings();
countDownLatch.countDown();
this.serializingExecutor.execute(new Runnable(this) { // from class: io.grpc.okhttp.OkHttpClientTransport.5
final OkHttpClientTransport this$0;
{
this.this$0 = this;
}
@Override // java.lang.Runnable
public void run() {
this.this$0.executor.execute(this.this$0.clientFrameHandler);
synchronized (this.this$0.lock) {
this.this$0.maxConcurrentStreams = Integer.MAX_VALUE;
this.this$0.startPendingStreams();
}
}
});
return null;
} catch (Throwable th) {
countDownLatch.countDown();
throw th;
}
}
void sendConnectionPrefaceAndSettings() {
synchronized (this.lock) {
this.frameWriter.connectionPreface();
Settings settings = new Settings();
OkHttpSettingsUtil.set(settings, 7, this.initialWindowSize);
this.frameWriter.settings(settings);
if (this.initialWindowSize > 65535) {
this.frameWriter.windowUpdate(0, r1 - 65535);
}
}
}
/* JADX INFO: Access modifiers changed from: private */
/* JADX WARN: Removed duplicated region for block: B:15:0x008a A[Catch: IOException -> 0x011e, TryCatch #2 {IOException -> 0x011e, blocks: (B:3:0x0006, B:5:0x000c, B:6:0x0029, B:8:0x006b, B:10:0x0071, B:12:0x0076, B:13:0x007a, B:15:0x008a, B:17:0x008f, B:19:0x0093, B:24:0x009d, B:25:0x00ab, B:29:0x00b6, B:31:0x00bc, B:35:0x00c3, B:41:0x00f5, B:42:0x011d, B:48:0x00d2, B:49:0x001b, B:37:0x00c8), top: B:2:0x0006, inners: #1 }] */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public java.net.Socket createHttpProxySocket(java.net.InetSocketAddress r17, java.net.InetSocketAddress r18, java.lang.String r19, java.lang.String r20) throws io.grpc.StatusException {
/*
Method dump skipped, instructions count: 304
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: io.grpc.okhttp.OkHttpClientTransport.createHttpProxySocket(java.net.InetSocketAddress, java.net.InetSocketAddress, java.lang.String, java.lang.String):java.net.Socket");
}
private C12995fNh createHttpProxyRequest(InetSocketAddress inetSocketAddress, String str, String str2) {
C12994fNg.IeS ieS = new C12994fNg.IeS();
ieS.j = "https";
String hostName = inetSocketAddress.getHostName();
if (hostName == null) {
throw new IllegalArgumentException("host == null");
}
String b = C12994fNg.IeS.b(hostName, 0, hostName.length());
if (b != null) {
ieS.i = b;
int port = inetSocketAddress.getPort();
if (port > 0 && port <= 65535) {
ieS.g = port;
C12994fNg e = ieS.e();
C12995fNh.LWm lWm = new C12995fNh.LWm();
lWm.d = e;
StringBuilder sb = new StringBuilder();
sb.append(e.d);
sb.append(":");
sb.append(e.b);
C12995fNh.LWm a = lWm.a(HttpHeaders.HOST, sb.toString()).a("User-Agent", this.userAgent);
if (str != null && str2 != null) {
a.a(HttpHeaders.PROXY_AUTHORIZATION, C12991fNd.e(str, str2));
}
if (a.d == null) {
throw new IllegalStateException("url == null");
}
return new C12995fNh(a, (byte) 0);
}
throw new IllegalArgumentException("unexpected port: ".concat(String.valueOf(port)));
}
throw new IllegalArgumentException("unexpected host: ".concat(String.valueOf(hostName)));
}
private static String readUtf8LineStrictUnbuffered(giD gid) throws IOException {
C15111ghZ c15111ghZ = new C15111ghZ();
while (gid.read(c15111ghZ, 1L) != -1) {
if (c15111ghZ.d(c15111ghZ.c - 1) == 10) {
return c15111ghZ.b(Long.MAX_VALUE);
}
}
StringBuilder sb = new StringBuilder("\\n not found: ");
sb.append(c15111ghZ.l().c());
throw new EOFException(sb.toString());
}
public String toString() {
return MoreObjects.toStringHelper(this).add("logId", this.logId.getId()).add(PlaceTypes.ADDRESS, this.address).toString();
}
String getOverridenHost() {
URI authorityToUri = GrpcUtil.authorityToUri(this.defaultAuthority);
return authorityToUri.getHost() != null ? authorityToUri.getHost() : this.defaultAuthority;
}
int getOverridenPort() {
URI authorityToUri = GrpcUtil.authorityToUri(this.defaultAuthority);
if (authorityToUri.getPort() != -1) {
return authorityToUri.getPort();
}
return this.address.getPort();
}
@Override // io.grpc.internal.ManagedClientTransport
public void shutdown(Status status) {
synchronized (this.lock) {
if (this.goAwayStatus != null) {
return;
}
this.goAwayStatus = status;
this.listener.transportShutdown(status);
stopIfNecessary();
}
}
@Override // io.grpc.internal.ManagedClientTransport
public void shutdownNow(Status status) {
shutdown(status);
synchronized (this.lock) {
Iterator<Map.Entry<Integer, OkHttpClientStream>> it = this.streams.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<Integer, OkHttpClientStream> next = it.next();
it.remove();
next.getValue().transportState().transportReportStatus(status, false, new Metadata());
maybeClearInUse(next.getValue());
}
for (OkHttpClientStream okHttpClientStream : this.pendingStreams) {
okHttpClientStream.transportState().transportReportStatus(status, true, new Metadata());
maybeClearInUse(okHttpClientStream);
}
this.pendingStreams.clear();
stopIfNecessary();
}
}
/* JADX INFO: Access modifiers changed from: package-private */
public OkHttpClientStream[] getActiveStreams() {
OkHttpClientStream[] okHttpClientStreamArr;
synchronized (this.lock) {
okHttpClientStreamArr = (OkHttpClientStream[]) this.streams.values().toArray(EMPTY_STREAM_ARRAY);
}
return okHttpClientStreamArr;
}
int getPendingStreamSize() {
int size;
synchronized (this.lock) {
size = this.pendingStreams.size();
}
return size;
}
@Override // io.grpc.okhttp.ExceptionHandlingFrameWriter.TransportExceptionHandler
public void onException(Throwable th) {
Preconditions.checkNotNull(th, "failureCause");
startGoAway(0, ErrorCode.INTERNAL_ERROR, Status.UNAVAILABLE.withCause(th));
}
/* JADX INFO: Access modifiers changed from: private */
public void onError(ErrorCode errorCode, String str) {
startGoAway(0, errorCode, toGrpcStatus(errorCode).augmentDescription(str));
}
/* JADX INFO: Access modifiers changed from: private */
public void startGoAway(int i, ErrorCode errorCode, Status status) {
synchronized (this.lock) {
if (this.goAwayStatus == null) {
this.goAwayStatus = status;
this.listener.transportShutdown(status);
}
if (errorCode != null && !this.goAwaySent) {
this.goAwaySent = true;
this.frameWriter.goAway(0, errorCode, new byte[0]);
}
Iterator<Map.Entry<Integer, OkHttpClientStream>> it = this.streams.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<Integer, OkHttpClientStream> next = it.next();
if (next.getKey().intValue() > i) {
it.remove();
next.getValue().transportState().transportReportStatus(status, ClientStreamListener.RpcProgress.REFUSED, false, new Metadata());
maybeClearInUse(next.getValue());
}
}
for (OkHttpClientStream okHttpClientStream : this.pendingStreams) {
okHttpClientStream.transportState().transportReportStatus(status, ClientStreamListener.RpcProgress.REFUSED, true, new Metadata());
maybeClearInUse(okHttpClientStream);
}
this.pendingStreams.clear();
stopIfNecessary();
}
}
/* JADX INFO: Access modifiers changed from: package-private */
public void finishStream(int i, Status status, ClientStreamListener.RpcProgress rpcProgress, boolean z, ErrorCode errorCode, Metadata metadata) {
synchronized (this.lock) {
OkHttpClientStream remove = this.streams.remove(Integer.valueOf(i));
if (remove != null) {
if (errorCode != null) {
this.frameWriter.rstStream(i, ErrorCode.CANCEL);
}
if (status != null) {
OkHttpClientStream.TransportState transportState = remove.transportState();
if (metadata == null) {
metadata = new Metadata();
}
transportState.transportReportStatus(status, rpcProgress, z, metadata);
}
if (!startPendingStreams()) {
stopIfNecessary();
maybeClearInUse(remove);
}
}
}
}
private void stopIfNecessary() {
if (this.goAwayStatus == null || !this.streams.isEmpty() || !this.pendingStreams.isEmpty() || this.stopped) {
return;
}
this.stopped = true;
KeepAliveManager keepAliveManager = this.keepAliveManager;
if (keepAliveManager != null) {
keepAliveManager.onTransportTermination();
this.scheduler = (ScheduledExecutorService) SharedResourceHolder.release(GrpcUtil.TIMER_SERVICE, this.scheduler);
}
Http2Ping http2Ping = this.ping;
if (http2Ping != null) {
http2Ping.failed(getPingFailure());
this.ping = null;
}
if (!this.goAwaySent) {
this.goAwaySent = true;
this.frameWriter.goAway(0, ErrorCode.NO_ERROR, new byte[0]);
}
this.frameWriter.close();
}
private void maybeClearInUse(OkHttpClientStream okHttpClientStream) {
if (this.hasStream && this.pendingStreams.isEmpty() && this.streams.isEmpty()) {
this.hasStream = false;
KeepAliveManager keepAliveManager = this.keepAliveManager;
if (keepAliveManager != null) {
keepAliveManager.onTransportIdle();
}
}
if (okHttpClientStream.shouldBeCountedForInUse()) {
this.inUseState.updateObjectInUse(okHttpClientStream, false);
}
}
private void setInUse(OkHttpClientStream okHttpClientStream) {
if (!this.hasStream) {
this.hasStream = true;
KeepAliveManager keepAliveManager = this.keepAliveManager;
if (keepAliveManager != null) {
keepAliveManager.onTransportActive();
}
}
if (okHttpClientStream.shouldBeCountedForInUse()) {
this.inUseState.updateObjectInUse(okHttpClientStream, true);
}
}
private Throwable getPingFailure() {
synchronized (this.lock) {
Status status = this.goAwayStatus;
if (status != null) {
return status.asException();
}
return Status.UNAVAILABLE.withDescription("Connection closed").asException();
}
}
/* JADX WARN: Code restructure failed: missing block: B:7:0x0009, code lost:
if ((r3 & 1) != 1) goto L8;
*/
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
boolean mayHaveCreatedStream(int r3) {
/*
r2 = this;
java.lang.Object r0 = r2.lock
monitor-enter(r0)
int r1 = r2.nextStreamId // Catch: java.lang.Throwable -> Le
if (r3 >= r1) goto Lb
r1 = 1
r3 = r3 & r1
if (r3 == r1) goto Lc
Lb:
r1 = 0
Lc:
monitor-exit(r0)
return r1
Le:
r3 = move-exception
monitor-exit(r0)
throw r3
*/
throw new UnsupportedOperationException("Method not decompiled: io.grpc.okhttp.OkHttpClientTransport.mayHaveCreatedStream(int):boolean");
}
/* JADX INFO: Access modifiers changed from: package-private */
public OkHttpClientStream getStream(int i) {
OkHttpClientStream okHttpClientStream;
synchronized (this.lock) {
okHttpClientStream = this.streams.get(Integer.valueOf(i));
}
return okHttpClientStream;
}
static Status toGrpcStatus(ErrorCode errorCode) {
Status status = ERROR_CODE_TO_STATUS.get(errorCode);
if (status != null) {
return status;
}
Status status2 = Status.UNKNOWN;
StringBuilder sb = new StringBuilder("Unknown http2 error code: ");
sb.append(errorCode.httpCode);
return status2.withDescription(sb.toString());
}
@Override // io.grpc.InternalInstrumented
public ListenableFuture<InternalChannelz.SocketStats> getStats() {
SettableFuture create = SettableFuture.create();
synchronized (this.lock) {
if (this.socket == null) {
create.set(new InternalChannelz.SocketStats(this.transportTracer.getStats(), null, null, new InternalChannelz.SocketOptions.Builder().build(), null));
} else {
create.set(new InternalChannelz.SocketStats(this.transportTracer.getStats(), this.socket.getLocalSocketAddress(), this.socket.getRemoteSocketAddress(), Utils.getSocketOptions(this.socket), this.securityInfo));
}
}
return create;
}
/* loaded from: classes6.dex */
class ClientFrameHandler implements FrameReader.Handler, Runnable {
boolean firstSettings;
FrameReader frameReader;
private final OkHttpFrameLogger logger;
final OkHttpClientTransport this$0;
@Override // io.grpc.okhttp.internal.framed.FrameReader.Handler
public void ackSettings() {
}
@Override // io.grpc.okhttp.internal.framed.FrameReader.Handler
public void alternateService(int i, String str, C15155gij c15155gij, String str2, int i2, long j) {
}
@Override // io.grpc.okhttp.internal.framed.FrameReader.Handler
public void priority(int i, int i2, int i3, boolean z) {
}
ClientFrameHandler(OkHttpClientTransport okHttpClientTransport, FrameReader frameReader) {
this(okHttpClientTransport, frameReader, new OkHttpFrameLogger(Level.FINE, (Class<?>) OkHttpClientTransport.class));
}
ClientFrameHandler(OkHttpClientTransport okHttpClientTransport, FrameReader frameReader, OkHttpFrameLogger okHttpFrameLogger) {
this.this$0 = okHttpClientTransport;
this.firstSettings = true;
this.frameReader = frameReader;
this.logger = okHttpFrameLogger;
}
@Override // java.lang.Runnable
public void run() {
FrameReader frameReader;
Status status;
String name = Thread.currentThread().getName();
Thread.currentThread().setName("OkHttpClientTransport");
while (this.frameReader.nextFrame(this)) {
try {
try {
if (this.this$0.keepAliveManager != null) {
this.this$0.keepAliveManager.onDataReceived();
}
} catch (Throwable th) {
try {
this.this$0.startGoAway(0, ErrorCode.PROTOCOL_ERROR, Status.INTERNAL.withDescription("error in frame handler").withCause(th));
frameReader = this.frameReader;
} catch (Throwable th2) {
try {
this.frameReader.close();
} catch (IOException e) {
OkHttpClientTransport.log.log(Level.INFO, "Exception closing frame reader", (Throwable) e);
}
this.this$0.listener.transportTerminated();
Thread.currentThread().setName(name);
throw th2;
}
}
} catch (IOException e2) {
OkHttpClientTransport.log.log(Level.INFO, "Exception closing frame reader", (Throwable) e2);
}
}
synchronized (this.this$0.lock) {
status = this.this$0.goAwayStatus;
}
if (status == null) {
status = Status.UNAVAILABLE.withDescription("End of stream or IOException");
}
this.this$0.startGoAway(0, ErrorCode.INTERNAL_ERROR, status);
frameReader = this.frameReader;
frameReader.close();
this.this$0.listener.transportTerminated();
Thread.currentThread().setName(name);
}
@Override // io.grpc.okhttp.internal.framed.FrameReader.Handler
public void data(boolean z, int i, InterfaceC15149gid interfaceC15149gid, int i2) throws IOException {
this.logger.logData(OkHttpFrameLogger.Direction.INBOUND, i, interfaceC15149gid.i(), i2, z);
OkHttpClientStream stream = this.this$0.getStream(i);
if (stream == null) {
if (this.this$0.mayHaveCreatedStream(i)) {
synchronized (this.this$0.lock) {
this.this$0.frameWriter.rstStream(i, ErrorCode.INVALID_STREAM);
}
interfaceC15149gid.j(i2);
} else {
this.this$0.onError(ErrorCode.PROTOCOL_ERROR, "Received data for unknown stream: ".concat(String.valueOf(i)));
return;
}
} else {
long j = i2;
interfaceC15149gid.g(j);
C15111ghZ c15111ghZ = new C15111ghZ();
c15111ghZ.write(interfaceC15149gid.i(), j);
stream.transportState().tag();
C13115fRJ.c();
synchronized (this.this$0.lock) {
stream.transportState().transportDataReceived(c15111ghZ, z);
}
}
OkHttpClientTransport.access$2412(this.this$0, i2);
if (this.this$0.connectionUnacknowledgedBytesRead >= this.this$0.initialWindowSize * 0.5f) {
synchronized (this.this$0.lock) {
this.this$0.frameWriter.windowUpdate(0, this.this$0.connectionUnacknowledgedBytesRead);
}
this.this$0.connectionUnacknowledgedBytesRead = 0;
}
}
@Override // io.grpc.okhttp.internal.framed.FrameReader.Handler
public void headers(boolean z, boolean z2, int i, int i2, List<Header> list, HeadersMode headersMode) {
Status status;
int headerBlockSize;
this.logger.logHeaders(OkHttpFrameLogger.Direction.INBOUND, i, list, z2);
boolean z3 = false;
if (this.this$0.maxInboundMetadataSize == Integer.MAX_VALUE || (headerBlockSize = headerBlockSize(list)) <= this.this$0.maxInboundMetadataSize) {
status = null;
} else {
Status status2 = Status.RESOURCE_EXHAUSTED;
Object[] objArr = new Object[3];
objArr[0] = z2 ? "trailer" : "header";
objArr[1] = Integer.valueOf(this.this$0.maxInboundMetadataSize);
objArr[2] = Integer.valueOf(headerBlockSize);
status = status2.withDescription(String.format("Response %s metadata larger than %d: %d", objArr));
}
synchronized (this.this$0.lock) {
OkHttpClientStream okHttpClientStream = (OkHttpClientStream) this.this$0.streams.get(Integer.valueOf(i));
if (okHttpClientStream == null) {
if (this.this$0.mayHaveCreatedStream(i)) {
this.this$0.frameWriter.rstStream(i, ErrorCode.INVALID_STREAM);
} else {
z3 = true;
}
} else if (status == null) {
okHttpClientStream.transportState().tag();
C13115fRJ.c();
okHttpClientStream.transportState().transportHeadersReceived(list, z2);
} else {
if (!z2) {
this.this$0.frameWriter.rstStream(i, ErrorCode.CANCEL);
}
okHttpClientStream.transportState().transportReportStatus(status, false, new Metadata());
}
}
if (z3) {
this.this$0.onError(ErrorCode.PROTOCOL_ERROR, "Received header for unknown stream: ".concat(String.valueOf(i)));
}
}
private int headerBlockSize(List<Header> list) {
long j = 0;
for (int i = 0; i < list.size(); i++) {
Header header = list.get(i);
j += header.name.a() + 32 + header.value.a();
}
return (int) Math.min(j, 2147483647L);
}
@Override // io.grpc.okhttp.internal.framed.FrameReader.Handler
public void rstStream(int i, ErrorCode errorCode) {
this.logger.logRstStream(OkHttpFrameLogger.Direction.INBOUND, i, errorCode);
Status augmentDescription = OkHttpClientTransport.toGrpcStatus(errorCode).augmentDescription("Rst Stream");
boolean z = augmentDescription.getCode() == Status.Code.CANCELLED || augmentDescription.getCode() == Status.Code.DEADLINE_EXCEEDED;
synchronized (this.this$0.lock) {
OkHttpClientStream okHttpClientStream = (OkHttpClientStream) this.this$0.streams.get(Integer.valueOf(i));
if (okHttpClientStream != null) {
okHttpClientStream.transportState().tag();
C13115fRJ.c();
this.this$0.finishStream(i, augmentDescription, errorCode == ErrorCode.REFUSED_STREAM ? ClientStreamListener.RpcProgress.REFUSED : ClientStreamListener.RpcProgress.PROCESSED, z, null, null);
}
}
}
@Override // io.grpc.okhttp.internal.framed.FrameReader.Handler
public void settings(boolean z, Settings settings) {
boolean z2;
this.logger.logSettings(OkHttpFrameLogger.Direction.INBOUND, settings);
synchronized (this.this$0.lock) {
if (OkHttpSettingsUtil.isSet(settings, 4)) {
this.this$0.maxConcurrentStreams = OkHttpSettingsUtil.get(settings, 4);
}
if (OkHttpSettingsUtil.isSet(settings, 7)) {
z2 = this.this$0.outboundFlow.initialOutboundWindowSize(OkHttpSettingsUtil.get(settings, 7));
} else {
z2 = false;
}
if (this.firstSettings) {
this.this$0.listener.transportReady();
this.firstSettings = false;
}
this.this$0.frameWriter.ackSettings(settings);
if (z2) {
this.this$0.outboundFlow.writeStreams();
}
this.this$0.startPendingStreams();
}
}
@Override // io.grpc.okhttp.internal.framed.FrameReader.Handler
public void ping(boolean z, int i, int i2) {
Http2Ping http2Ping;
long j = (i << 32) | (i2 & KeyboardMap.kValueMask);
this.logger.logPing(OkHttpFrameLogger.Direction.INBOUND, j);
if (!z) {
synchronized (this.this$0.lock) {
this.this$0.frameWriter.ping(true, i, i2);
}
return;
}
synchronized (this.this$0.lock) {
http2Ping = null;
if (this.this$0.ping == null) {
OkHttpClientTransport.log.warning("Received unexpected ping ack. No ping outstanding");
} else if (this.this$0.ping.payload() == j) {
Http2Ping http2Ping2 = this.this$0.ping;
this.this$0.ping = null;
http2Ping = http2Ping2;
} else {
OkHttpClientTransport.log.log(Level.WARNING, String.format("Received unexpected ping ack. Expecting %d, got %d", Long.valueOf(this.this$0.ping.payload()), Long.valueOf(j)));
}
}
if (http2Ping != null) {
http2Ping.complete();
}
}
@Override // io.grpc.okhttp.internal.framed.FrameReader.Handler
public void goAway(int i, ErrorCode errorCode, C15155gij c15155gij) {
this.logger.logGoAway(OkHttpFrameLogger.Direction.INBOUND, i, errorCode, c15155gij);
if (errorCode == ErrorCode.ENHANCE_YOUR_CALM) {
String str = c15155gij.d;
if (str == null) {
byte[] b = c15155gij.b();
C14957gcv.e(b, "");
String str2 = new String(b, gdP.a);
c15155gij.d = str2;
str = str2;
}
OkHttpClientTransport.log.log(Level.WARNING, String.format("%s: Received GOAWAY with ENHANCE_YOUR_CALM. Debug data: %s", this, str));
if ("too_many_pings".equals(str)) {
this.this$0.tooManyPingsRunnable.run();
}
}
Status augmentDescription = GrpcUtil.Http2Error.statusForCode(errorCode.httpCode).augmentDescription("Received Goaway");
if (c15155gij.a() > 0) {
String str3 = c15155gij.d;
if (str3 == null) {
byte[] b2 = c15155gij.b();
C14957gcv.e(b2, "");
String str4 = new String(b2, gdP.a);
c15155gij.d = str4;
str3 = str4;
}
augmentDescription = augmentDescription.augmentDescription(str3);
}
this.this$0.startGoAway(i, null, augmentDescription);
}
@Override // io.grpc.okhttp.internal.framed.FrameReader.Handler
public void pushPromise(int i, int i2, List<Header> list) throws IOException {
this.logger.logPushPromise(OkHttpFrameLogger.Direction.INBOUND, i, i2, list);
synchronized (this.this$0.lock) {
this.this$0.frameWriter.rstStream(i, ErrorCode.PROTOCOL_ERROR);
}
}
/* JADX WARN: Removed duplicated region for block: B:22:0x006f */
/* JADX WARN: Removed duplicated region for block: B:24:? A[RETURN, SYNTHETIC] */
@Override // io.grpc.okhttp.internal.framed.FrameReader.Handler
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public void windowUpdate(int r8, long r9) {
/*
r7 = this;
io.grpc.okhttp.OkHttpFrameLogger r0 = r7.logger
io.grpc.okhttp.OkHttpFrameLogger$Direction r1 = io.grpc.okhttp.OkHttpFrameLogger.Direction.INBOUND
r0.logWindowsUpdate(r1, r8, r9)
r0 = 0
int r0 = (r9 > r0 ? 1 : (r9 == r0 ? 0 : -1))
if (r0 != 0) goto L2e
if (r8 != 0) goto L19
io.grpc.okhttp.OkHttpClientTransport r8 = r7.this$0
io.grpc.okhttp.internal.framed.ErrorCode r9 = io.grpc.okhttp.internal.framed.ErrorCode.PROTOCOL_ERROR
java.lang.String r10 = "Received 0 flow control window increment."
io.grpc.okhttp.OkHttpClientTransport.access$2300(r8, r9, r10)
return
L19:
io.grpc.okhttp.OkHttpClientTransport r0 = r7.this$0
io.grpc.Status r9 = io.grpc.Status.INTERNAL
java.lang.String r10 = "Received 0 flow control window increment."
io.grpc.Status r2 = r9.withDescription(r10)
io.grpc.internal.ClientStreamListener$RpcProgress r3 = io.grpc.internal.ClientStreamListener.RpcProgress.PROCESSED
io.grpc.okhttp.internal.framed.ErrorCode r5 = io.grpc.okhttp.internal.framed.ErrorCode.PROTOCOL_ERROR
r4 = 0
r6 = 0
r1 = r8
r0.finishStream(r1, r2, r3, r4, r5, r6)
return
L2e:
io.grpc.okhttp.OkHttpClientTransport r0 = r7.this$0
java.lang.Object r0 = io.grpc.okhttp.OkHttpClientTransport.access$100(r0)
monitor-enter(r0)
if (r8 != 0) goto L44
io.grpc.okhttp.OkHttpClientTransport r8 = r7.this$0 // Catch: java.lang.Throwable -> L81
io.grpc.okhttp.OutboundFlowController r8 = io.grpc.okhttp.OkHttpClientTransport.access$200(r8) // Catch: java.lang.Throwable -> L81
r1 = 0
int r9 = (int) r9 // Catch: java.lang.Throwable -> L81
r8.windowUpdate(r1, r9) // Catch: java.lang.Throwable -> L81
monitor-exit(r0)
return
L44:
io.grpc.okhttp.OkHttpClientTransport r1 = r7.this$0 // Catch: java.lang.Throwable -> L81
java.util.Map r1 = io.grpc.okhttp.OkHttpClientTransport.access$2700(r1) // Catch: java.lang.Throwable -> L81
java.lang.Integer r2 = java.lang.Integer.valueOf(r8) // Catch: java.lang.Throwable -> L81
java.lang.Object r1 = r1.get(r2) // Catch: java.lang.Throwable -> L81
io.grpc.okhttp.OkHttpClientStream r1 = (io.grpc.okhttp.OkHttpClientStream) r1 // Catch: java.lang.Throwable -> L81
if (r1 == 0) goto L61
io.grpc.okhttp.OkHttpClientTransport r2 = r7.this$0 // Catch: java.lang.Throwable -> L81
io.grpc.okhttp.OutboundFlowController r2 = io.grpc.okhttp.OkHttpClientTransport.access$200(r2) // Catch: java.lang.Throwable -> L81
int r9 = (int) r9 // Catch: java.lang.Throwable -> L81
r2.windowUpdate(r1, r9) // Catch: java.lang.Throwable -> L81
goto L6b
L61:
io.grpc.okhttp.OkHttpClientTransport r9 = r7.this$0 // Catch: java.lang.Throwable -> L81
boolean r9 = r9.mayHaveCreatedStream(r8) // Catch: java.lang.Throwable -> L81
if (r9 != 0) goto L6b
r9 = 1
goto L6c
L6b:
r9 = 0
L6c:
monitor-exit(r0)
if (r9 == 0) goto L80
io.grpc.okhttp.OkHttpClientTransport r9 = r7.this$0
io.grpc.okhttp.internal.framed.ErrorCode r10 = io.grpc.okhttp.internal.framed.ErrorCode.PROTOCOL_ERROR
java.lang.String r0 = "Received window_update for unknown stream: "
java.lang.String r8 = java.lang.String.valueOf(r8)
java.lang.String r8 = r0.concat(r8)
io.grpc.okhttp.OkHttpClientTransport.access$2300(r9, r10, r8)
L80:
return
L81:
r8 = move-exception
monitor-exit(r0)
throw r8
*/
throw new UnsupportedOperationException("Method not decompiled: io.grpc.okhttp.OkHttpClientTransport.ClientFrameHandler.windowUpdate(int, long):void");
}
}
/* JADX INFO: Access modifiers changed from: package-private */
public boolean isUsingPlaintext() {
return this.sslSocketFactory == null;
}
SocketFactory getSocketFactory() {
return this.socketFactory;
}
@Override // io.grpc.InternalWithLogId
public InternalLogId getLogId() {
return this.logId;
}
ClientFrameHandler getHandler() {
return this.clientFrameHandler;
}
@Override // io.grpc.internal.ConnectionClientTransport
public Attributes getAttributes() {
return this.attributes;
}
/* JADX INFO: Access modifiers changed from: package-private */
public void enableKeepAlive(boolean z, long j, long j2, boolean z2) {
this.enableKeepAlive = z;
this.keepAliveTimeNanos = j;
this.keepAliveTimeoutNanos = j2;
this.keepAliveWithoutCalls = z2;
}
private boolean isForTest() {
return this.address == null;
}
}