package com.google.common.util.concurrent; import com.google.common.base.Function; import com.google.common.base.Preconditions; import com.google.common.util.concurrent.FluentFuture; import java.lang.Throwable; import java.util.concurrent.Executor; import javax.annotation.CheckForNull; /* JADX INFO: Access modifiers changed from: package-private */ @ElementTypesAreNonnullByDefault /* loaded from: classes3.dex */ public abstract class AbstractCatchingFuture<V, X extends Throwable, F, T> extends FluentFuture.TrustedFuture<V> implements Runnable { @CheckForNull Class<X> exceptionType; @CheckForNull F fallback; @CheckForNull ListenableFuture<? extends V> inputFuture; @ParametricNullness abstract T doFallback(F f, X x) throws Exception; abstract void setResult(@ParametricNullness T t); /* JADX INFO: Access modifiers changed from: package-private */ public static <V, X extends Throwable> ListenableFuture<V> create(ListenableFuture<? extends V> listenableFuture, Class<X> cls, Function<? super X, ? extends V> function, Executor executor) { CatchingFuture catchingFuture = new CatchingFuture(listenableFuture, cls, function); listenableFuture.addListener(catchingFuture, MoreExecutors.rejectionPropagatingExecutor(executor, catchingFuture)); return catchingFuture; } /* JADX INFO: Access modifiers changed from: package-private */ public static <X extends Throwable, V> ListenableFuture<V> create(ListenableFuture<? extends V> listenableFuture, Class<X> cls, AsyncFunction<? super X, ? extends V> asyncFunction, Executor executor) { AsyncCatchingFuture asyncCatchingFuture = new AsyncCatchingFuture(listenableFuture, cls, asyncFunction); listenableFuture.addListener(asyncCatchingFuture, MoreExecutors.rejectionPropagatingExecutor(executor, asyncCatchingFuture)); return asyncCatchingFuture; } AbstractCatchingFuture(ListenableFuture<? extends V> listenableFuture, Class<X> cls, F f) { this.inputFuture = (ListenableFuture) Preconditions.checkNotNull(listenableFuture); this.exceptionType = (Class) Preconditions.checkNotNull(cls); this.fallback = (F) Preconditions.checkNotNull(f); } /* JADX WARN: Multi-variable type inference failed */ /* JADX WARN: Removed duplicated region for block: B:21:0x0092 */ /* JADX WARN: Removed duplicated region for block: B:24:0x009a */ /* JADX WARN: Type inference failed for: r3v4, types: [java.lang.Class<X extends java.lang.Throwable>, F] */ @Override // java.lang.Runnable /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public final void run() { /* r9 = this; com.google.common.util.concurrent.ListenableFuture<? extends V> r0 = r9.inputFuture java.lang.Class<X extends java.lang.Throwable> r1 = r9.exceptionType F r2 = r9.fallback r3 = 1 r4 = 0 if (r0 != 0) goto Lc r5 = r3 goto Ld Lc: r5 = r4 Ld: if (r1 != 0) goto L11 r6 = r3 goto L12 L11: r6 = r4 L12: r5 = r5 | r6 if (r2 != 0) goto L16 goto L17 L16: r3 = r4 L17: r3 = r3 | r5 if (r3 != 0) goto Lbf boolean r3 = r9.isCancelled() if (r3 == 0) goto L22 goto Lbf L22: r3 = 0 r9.inputFuture = r3 boolean r4 = r0 instanceof com.google.common.util.concurrent.internal.InternalFutureFailureAccess // Catch: java.lang.Throwable -> L39 java.util.concurrent.ExecutionException -> L3c if (r4 == 0) goto L31 r4 = r0 com.google.common.util.concurrent.internal.InternalFutureFailureAccess r4 = (com.google.common.util.concurrent.internal.InternalFutureFailureAccess) r4 // Catch: java.lang.Throwable -> L39 java.util.concurrent.ExecutionException -> L3c java.lang.Throwable r4 = com.google.common.util.concurrent.internal.InternalFutures.tryInternalFastPathGetFailure(r4) // Catch: java.lang.Throwable -> L39 java.util.concurrent.ExecutionException -> L3c goto L32 L31: r4 = r3 L32: if (r4 != 0) goto L3a java.lang.Object r5 = com.google.common.util.concurrent.Futures.getDone(r0) // Catch: java.lang.Throwable -> L39 java.util.concurrent.ExecutionException -> L3c goto L90 L39: r4 = move-exception L3a: r5 = r3 goto L90 L3c: r4 = move-exception java.lang.Throwable r5 = r4.getCause() if (r5 != 0) goto L8e java.lang.NullPointerException r5 = new java.lang.NullPointerException java.lang.Class r6 = r0.getClass() java.lang.String r6 = java.lang.String.valueOf(r6) java.lang.Class r4 = r4.getClass() java.lang.String r4 = java.lang.String.valueOf(r4) java.lang.String r7 = java.lang.String.valueOf(r6) int r7 = r7.length() int r7 = r7 + 35 java.lang.String r8 = java.lang.String.valueOf(r4) int r8 = r8.length() int r7 = r7 + r8 java.lang.StringBuilder r8 = new java.lang.StringBuilder r8.<init>(r7) java.lang.String r7 = "Future type " java.lang.StringBuilder r7 = r8.append(r7) java.lang.StringBuilder r6 = r7.append(r6) java.lang.String r7 = " threw " java.lang.StringBuilder r6 = r6.append(r7) java.lang.StringBuilder r4 = r6.append(r4) java.lang.String r6 = " without a cause" java.lang.StringBuilder r4 = r4.append(r6) java.lang.String r4 = r4.toString() r5.<init>(r4) L8e: r4 = r5 goto L3a L90: if (r4 != 0) goto L9a java.lang.Object r0 = com.google.common.util.concurrent.NullnessCasts.uncheckedCastNullableTToT(r5) r9.set(r0) return L9a: boolean r1 = com.google.common.util.concurrent.Platform.isInstanceOfThrowableClass(r4, r1) if (r1 != 0) goto La4 r9.setFuture(r0) return La4: java.lang.Object r0 = r9.doFallback(r2, r4) // Catch: java.lang.Throwable -> Lb0 r9.exceptionType = r3 r9.fallback = r3 r9.setResult(r0) return Lb0: r0 = move-exception r9.setException(r0) // Catch: java.lang.Throwable -> Lb9 r9.exceptionType = r3 r9.fallback = r3 return Lb9: r0 = move-exception r9.exceptionType = r3 r9.fallback = r3 throw r0 Lbf: return */ throw new UnsupportedOperationException("Method not decompiled: com.google.common.util.concurrent.AbstractCatchingFuture.run():void"); } /* JADX INFO: Access modifiers changed from: protected */ @Override // com.google.common.util.concurrent.AbstractFuture @CheckForNull public String pendingToString() { String str; ListenableFuture<? extends V> listenableFuture = this.inputFuture; Class<X> cls = this.exceptionType; F f = this.fallback; String pendingToString = super.pendingToString(); if (listenableFuture != null) { String valueOf = String.valueOf(listenableFuture); str = new StringBuilder(String.valueOf(valueOf).length() + 16).append("inputFuture=[").append(valueOf).append("], ").toString(); } else { str = ""; } if (cls != null && f != null) { String valueOf2 = String.valueOf(cls); String valueOf3 = String.valueOf(f); return new StringBuilder(String.valueOf(str).length() + 29 + String.valueOf(valueOf2).length() + String.valueOf(valueOf3).length()).append(str).append("exceptionType=[").append(valueOf2).append("], fallback=[").append(valueOf3).append("]").toString(); } if (pendingToString == null) { return null; } String valueOf4 = String.valueOf(str); String valueOf5 = String.valueOf(pendingToString); return valueOf5.length() != 0 ? valueOf4.concat(valueOf5) : new String(valueOf4); } /* JADX INFO: Access modifiers changed from: protected */ @Override // com.google.common.util.concurrent.AbstractFuture public final void afterDone() { maybePropagateCancellationTo(this.inputFuture); this.inputFuture = null; this.exceptionType = null; this.fallback = null; } /* JADX INFO: Access modifiers changed from: private */ /* loaded from: classes3.dex */ public static final class AsyncCatchingFuture<V, X extends Throwable> extends AbstractCatchingFuture<V, X, AsyncFunction<? super X, ? extends V>, ListenableFuture<? extends V>> { /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.util.concurrent.AbstractCatchingFuture /* bridge */ /* synthetic */ Object doFallback(Object obj, Throwable th) throws Exception { return doFallback((AsyncFunction<? super AsyncFunction<? super X, ? extends V>, ? extends V>) obj, (AsyncFunction<? super X, ? extends V>) th); } AsyncCatchingFuture(ListenableFuture<? extends V> listenableFuture, Class<X> cls, AsyncFunction<? super X, ? extends V> asyncFunction) { super(listenableFuture, cls, asyncFunction); } /* JADX WARN: Multi-variable type inference failed */ ListenableFuture<? extends V> doFallback(AsyncFunction<? super X, ? extends V> asyncFunction, X x) throws Exception { ListenableFuture<? extends V> apply = asyncFunction.apply(x); Preconditions.checkNotNull(apply, "AsyncFunction.apply returned null instead of a Future. Did you mean to return immediateFuture(null)? %s", asyncFunction); return apply; } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.util.concurrent.AbstractCatchingFuture public void setResult(ListenableFuture<? extends V> listenableFuture) { setFuture(listenableFuture); } } /* JADX INFO: Access modifiers changed from: private */ /* loaded from: classes3.dex */ public static final class CatchingFuture<V, X extends Throwable> extends AbstractCatchingFuture<V, X, Function<? super X, ? extends V>, V> { /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.util.concurrent.AbstractCatchingFuture @ParametricNullness /* bridge */ /* synthetic */ Object doFallback(Object obj, Throwable th) throws Exception { return doFallback((Function<? super Function<? super X, ? extends V>, ? extends V>) obj, (Function<? super X, ? extends V>) th); } CatchingFuture(ListenableFuture<? extends V> listenableFuture, Class<X> cls, Function<? super X, ? extends V> function) { super(listenableFuture, cls, function); } /* JADX WARN: Multi-variable type inference failed */ @ParametricNullness V doFallback(Function<? super X, ? extends V> function, X x) throws Exception { return function.apply(x); } @Override // com.google.common.util.concurrent.AbstractCatchingFuture void setResult(@ParametricNullness V v) { set(v); } } }