package com.google.android.gms.internal.ads;

import java.util.concurrent.ExecutionException;

/* JADX INFO: loaded from: classes2.dex */
public abstract class vt1 extends vu1 implements Runnable {

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public static final /* synthetic */ int f17769k = 0;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public com.google.common.util.concurrent.w f17770h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public Class f17771i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public Object f17772j;

    public vt1(com.google.common.util.concurrent.w wVar, Class cls, Object obj) {
        wVar.getClass();
        this.f17770h = wVar;
        this.f17771i = cls;
        this.f17772j = obj;
    }

    @Override // com.google.android.gms.internal.ads.cu1
    public final void e() {
        o(this.f17770h);
        this.f17770h = null;
        this.f17771i = null;
        this.f17772j = null;
    }

    @Override // com.google.android.gms.internal.ads.cu1
    public final String f() {
        String strP;
        com.google.common.util.concurrent.w wVar = this.f17770h;
        Class cls = this.f17771i;
        Object obj = this.f17772j;
        String strF = super.f();
        if (wVar != null) {
            String string = wVar.toString();
            strP = defpackage.e.p(new StringBuilder(string.length() + 16), "inputFuture=[", string, "], ");
        } else {
            strP = "";
        }
        if (cls == null || obj == null) {
            if (strF != null) {
                return strP.concat(strF);
            }
            return null;
        }
        int length = strP.length();
        String string2 = cls.toString();
        int length2 = string2.length();
        String string3 = obj.toString();
        StringBuilder sb = new StringBuilder(string3.length() + length + 15 + length2 + 13 + 1);
        u.a.h(sb, strP, "exceptionType=[", string2, "], fallback=[");
        return defpackage.e.o(sb, string3, "]");
    }

    /* JADX WARN: Multi-variable type inference failed */
    @Override // java.lang.Runnable
    public final void run() {
        com.google.common.util.concurrent.w wVar = this.f17770h;
        Class cls = this.f17771i;
        Object obj = this.f17772j;
        if (((obj == null) || ((wVar == 0) | (cls == null))) || (this.f11887a instanceof wt1)) {
            return;
        }
        this.f17770h = null;
        try {
            th = wVar instanceof pv1 ? ((pv1) wVar).a() : null;
        } catch (ExecutionException e10) {
            Throwable cause = e10.getCause();
            if (cause == null) {
                String strValueOf = String.valueOf(wVar.getClass());
                String strValueOf2 = String.valueOf(e10.getClass());
                StringBuilder sb = new StringBuilder(strValueOf2.length() + strValueOf.length() + 19 + 16);
                u.a.h(sb, "Future type ", strValueOf, " threw ", strValueOf2);
                sb.append(" without a cause");
                cause = new NullPointerException(sb.toString());
            }
            th = cause;
        } catch (Throwable th) {
            th = th;
        }
        Object objA1 = th == null ? ih1.A1(wVar) : null;
        if (th == null) {
            c(objA1);
            return;
        }
        if (!cls.isInstance(th)) {
            n(wVar);
            return;
        }
        try {
            Object objU = u(obj, th);
            this.f17771i = null;
            this.f17772j = null;
            t(objU);
        } catch (Throwable th2) {
            try {
                if (th2 instanceof InterruptedException) {
                    Thread.currentThread().interrupt();
                }
                d(th2);
            } finally {
                this.f17771i = null;
                this.f17772j = null;
            }
        }
    }

    public abstract void t(Object obj);

    public abstract Object u(Object obj, Throwable th);
}
