package defpackage;

import java.io.IOException;
import java.net.ProtocolException;

/* renamed from: ᵭˀʿᵡ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C4095 extends AbstractC0518 {

    /* renamed from: ᵡⁱᵥ, reason: contains not printable characters */
    public final /* synthetic */ C2729 f15303;

    /* renamed from: ᵤᵙᵷ, reason: contains not printable characters */
    public long f15304;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public C4095(C2729 c2729, C1489 c1489, long j) throws NumberFormatException {
        super(c2729, c1489);
        this.f15303 = c2729;
        this.f15304 = j;
        if (j == 0) {
            m2228(C2609.f10095);
        }
    }

    @Override // java.io.Closeable, java.lang.AutoCloseable
    public final void close() {
        boolean zM8923;
        if (this.f2685) {
            return;
        }
        if (this.f15304 != 0) {
            try {
                zM8923 = AbstractC4061.m8923(this, 100);
            } catch (IOException unused) {
                zM8923 = false;
            }
            if (!zM8923) {
                this.f15303.f10567.mo2589();
                m2228(C2729.f10563);
            }
        }
        this.f2685 = true;
    }

    @Override // defpackage.AbstractC0518, defpackage.InterfaceC3226
    /* renamed from: ᵳٴᵶ */
    public final long mo2229(C0963 c0963, long j) throws NumberFormatException, IOException {
        if (this.f2685) {
            ᵹˉᵞ.ᵳٴᵶ("closed");
            return 0L;
        }
        long j2 = this.f15304;
        if (j2 == 0) {
            return -1L;
        }
        long jMo2229 = super.mo2229(c0963, Math.min(j2, 8192L));
        if (jMo2229 == -1) {
            this.f15303.f10567.mo2589();
            ProtocolException protocolException = new ProtocolException("unexpected end of stream");
            m2228(C2729.f10563);
            throw protocolException;
        }
        long j3 = this.f15304 - jMo2229;
        this.f15304 = j3;
        if (j3 == 0) {
            m2228(C2609.f10095);
        }
        return jMo2229;
    }
}
