package o7;

import java.io.IOException;
import java.util.concurrent.atomic.AtomicInteger;
import k7.InterfaceC1113e;
import s7.n;

/* JADX INFO: loaded from: classes.dex */
public final class f implements Runnable {

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public final InterfaceC1113e f15960q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public volatile AtomicInteger f15961r = new AtomicInteger(0);

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public final /* synthetic */ i f15962s;

    public f(i iVar, InterfaceC1113e interfaceC1113e) {
        this.f15962s = iVar;
        this.f15960q = interfaceC1113e;
    }

    @Override // java.lang.Runnable
    public final void run() {
        C2.a aVar;
        String strConcat = "OkHttp ".concat(this.f15962s.f15970r.f14202a.g());
        i iVar = this.f15962s;
        Thread threadCurrentThread = Thread.currentThread();
        String name = threadCurrentThread.getName();
        threadCurrentThread.setName(strConcat);
        try {
            iVar.f15972t.h();
            boolean z8 = false;
            try {
                try {
                } catch (Throwable th) {
                    iVar.f15969q.f14184q.p(this);
                    throw th;
                }
            } catch (IOException e8) {
                e = e8;
            } catch (Throwable th2) {
                th = th2;
            }
            try {
                this.f15960q.B(iVar.i());
                aVar = iVar.f15969q.f14184q;
            } catch (IOException e9) {
                e = e9;
                z8 = true;
                if (z8) {
                    n nVar = n.f16942a;
                    n nVar2 = n.f16942a;
                    String str = "Callback failure for " + i.c(iVar);
                    nVar2.getClass();
                    n.i(str, 4, e);
                } else {
                    this.f15960q.x(iVar, e);
                }
                aVar = iVar.f15969q.f14184q;
            } catch (Throwable th3) {
                th = th3;
                z8 = true;
                iVar.cancel();
                if (!z8) {
                    IOException iOException = new IOException("canceled due to " + th);
                    android.support.v4.media.session.a.a(iOException, th);
                    this.f15960q.x(iVar, iOException);
                }
                throw th;
            }
            aVar.p(this);
        } finally {
            threadCurrentThread.setName(name);
        }
    }
}
