package n4;

import androidx.recyclerview.widget.i0;
import java.io.IOException;
import java.util.Map;
import java.util.logging.Level;
import k4.r0;
import m4.A0;
import p4.C2729h;
import p4.EnumC2722a;

/* JADX INFO: loaded from: classes3.dex */
public final class m implements Runnable {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final i0 f21702a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final C2729h f21703b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public boolean f21704c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final /* synthetic */ n f21705d;

    public m(n nVar, C2729h c2729h) {
        this.f21705d = nVar;
        Level level = Level.FINE;
        this.f21702a = new i0(9);
        this.f21704c = true;
        this.f21703b = c2729h;
    }

    @Override // java.lang.Runnable
    public final void run() {
        n nVar;
        r0 r0VarG;
        String name = Thread.currentThread().getName();
        Thread.currentThread().setName("OkHttpClientTransport");
        while (this.f21703b.a(this)) {
            try {
                A0 a02 = this.f21705d.f21713F;
                if (a02 != null) {
                    a02.a();
                }
            } catch (Throwable th) {
                try {
                    n nVar2 = this.f21705d;
                    EnumC2722a enumC2722a = EnumC2722a.PROTOCOL_ERROR;
                    r0 r0VarF = r0.f19945m.g("error in frame handler").f(th);
                    Map map = n.f21706P;
                    nVar2.s(0, enumC2722a, r0VarF);
                    try {
                        this.f21703b.close();
                    } catch (IOException e6) {
                        n.f21707Q.log(Level.INFO, "Exception closing frame reader", (Throwable) e6);
                    } catch (RuntimeException e7) {
                        if (!"bio == null".equals(e7.getMessage())) {
                            throw e7;
                        }
                    }
                    nVar = this.f21705d;
                } catch (Throwable th2) {
                    try {
                        this.f21703b.close();
                    } catch (IOException e8) {
                        n.f21707Q.log(Level.INFO, "Exception closing frame reader", (Throwable) e8);
                    } catch (RuntimeException e9) {
                        if (!"bio == null".equals(e9.getMessage())) {
                            throw e9;
                        }
                    }
                    this.f21705d.f21730h.i();
                    Thread.currentThread().setName(name);
                    throw th2;
                }
            }
        }
        synchronized (this.f21705d.f21733k) {
            r0VarG = this.f21705d.f21743v;
        }
        if (r0VarG == null) {
            r0VarG = r0.f19946n.g("End of stream or IOException");
        }
        this.f21705d.s(0, EnumC2722a.INTERNAL_ERROR, r0VarG);
        try {
            this.f21703b.close();
        } catch (IOException e10) {
            n.f21707Q.log(Level.INFO, "Exception closing frame reader", (Throwable) e10);
        } catch (RuntimeException e11) {
            if (!"bio == null".equals(e11.getMessage())) {
                throw e11;
            }
        }
        nVar = this.f21705d;
        nVar.f21730h.i();
        Thread.currentThread().setName(name);
    }
}
