260 lines
11 KiB
Java
260 lines
11 KiB
Java
|
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;
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* loaded from: classes2.dex */
|
||
|
public abstract class AbstractCatchingFuture<V, X extends Throwable, F, T> extends FluentFuture.TrustedFuture<V> implements Runnable {
|
||
|
Class<X> exceptionType;
|
||
|
F fallback;
|
||
|
ListenableFuture<? extends V> inputFuture;
|
||
|
|
||
|
abstract T doFallback(F f, X x) throws Exception;
|
||
|
|
||
|
abstract void setResult(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:18:0x008d */
|
||
|
/* JADX WARN: Removed duplicated region for block: B:21:0x0091 */
|
||
|
/* 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() {
|
||
|
/*
|
||
|
r10 = this;
|
||
|
com.google.common.util.concurrent.ListenableFuture<? extends V> r0 = r10.inputFuture
|
||
|
java.lang.Class<X extends java.lang.Throwable> r1 = r10.exceptionType
|
||
|
F r2 = r10.fallback
|
||
|
r3 = 0
|
||
|
r4 = 1
|
||
|
if (r0 != 0) goto Lc
|
||
|
r5 = r4
|
||
|
goto Ld
|
||
|
Lc:
|
||
|
r5 = r3
|
||
|
Ld:
|
||
|
if (r1 != 0) goto L11
|
||
|
r6 = r4
|
||
|
goto L12
|
||
|
L11:
|
||
|
r6 = r3
|
||
|
L12:
|
||
|
if (r2 == 0) goto L15
|
||
|
goto L16
|
||
|
L15:
|
||
|
r3 = r4
|
||
|
L16:
|
||
|
r4 = r5 | r6
|
||
|
r3 = r3 | r4
|
||
|
if (r3 != 0) goto Lb6
|
||
|
boolean r3 = r10.isCancelled()
|
||
|
if (r3 != 0) goto Lb6
|
||
|
r3 = 0
|
||
|
r10.inputFuture = r3
|
||
|
boolean r4 = r0 instanceof com.google.common.util.concurrent.internal.InternalFutureFailureAccess
|
||
|
if (r4 == 0) goto L34
|
||
|
r4 = r0
|
||
|
com.google.common.util.concurrent.internal.InternalFutureFailureAccess r4 = (com.google.common.util.concurrent.internal.InternalFutureFailureAccess) r4 // Catch: java.lang.Throwable -> L30 java.util.concurrent.ExecutionException -> L32
|
||
|
java.lang.Throwable r4 = com.google.common.util.concurrent.internal.InternalFutures.tryInternalFastPathGetFailure(r4) // Catch: java.lang.Throwable -> L30 java.util.concurrent.ExecutionException -> L32
|
||
|
goto L35
|
||
|
L30:
|
||
|
r4 = move-exception
|
||
|
goto L8a
|
||
|
L32:
|
||
|
r4 = move-exception
|
||
|
goto L3c
|
||
|
L34:
|
||
|
r4 = r3
|
||
|
L35:
|
||
|
if (r4 != 0) goto L8a
|
||
|
java.lang.Object r5 = com.google.common.util.concurrent.Futures.getDone(r0) // Catch: java.lang.Throwable -> L30 java.util.concurrent.ExecutionException -> L32
|
||
|
goto L8b
|
||
|
L3c:
|
||
|
java.lang.Throwable r5 = r4.getCause()
|
||
|
if (r5 != 0) goto L89
|
||
|
java.lang.Class r5 = r0.getClass()
|
||
|
java.lang.String r5 = java.lang.String.valueOf(r5)
|
||
|
java.lang.Class r4 = r4.getClass()
|
||
|
java.lang.String r4 = java.lang.String.valueOf(r4)
|
||
|
java.lang.NullPointerException r6 = new java.lang.NullPointerException
|
||
|
java.lang.StringBuilder r7 = new java.lang.StringBuilder
|
||
|
java.lang.String r8 = java.lang.String.valueOf(r5)
|
||
|
int r8 = r8.length()
|
||
|
int r8 = r8 + 35
|
||
|
java.lang.String r9 = java.lang.String.valueOf(r4)
|
||
|
int r9 = r9.length()
|
||
|
int r8 = r8 + r9
|
||
|
r7.<init>(r8)
|
||
|
java.lang.String r8 = "Future type "
|
||
|
r7.append(r8)
|
||
|
r7.append(r5)
|
||
|
java.lang.String r5 = " threw "
|
||
|
r7.append(r5)
|
||
|
r7.append(r4)
|
||
|
java.lang.String r4 = " without a cause"
|
||
|
r7.append(r4)
|
||
|
java.lang.String r4 = r7.toString()
|
||
|
r6.<init>(r4)
|
||
|
r5 = r6
|
||
|
L89:
|
||
|
r4 = r5
|
||
|
L8a:
|
||
|
r5 = r3
|
||
|
L8b:
|
||
|
if (r4 != 0) goto L91
|
||
|
r10.set(r5)
|
||
|
return
|
||
|
L91:
|
||
|
boolean r1 = com.google.common.util.concurrent.Platform.isInstanceOfThrowableClass(r4, r1)
|
||
|
if (r1 != 0) goto L9b
|
||
|
r10.setFuture(r0)
|
||
|
return
|
||
|
L9b:
|
||
|
java.lang.Object r0 = r10.doFallback(r2, r4) // Catch: java.lang.Throwable -> La7
|
||
|
r10.exceptionType = r3
|
||
|
r10.fallback = r3
|
||
|
r10.setResult(r0)
|
||
|
return
|
||
|
La7:
|
||
|
r0 = move-exception
|
||
|
r10.setException(r0) // Catch: java.lang.Throwable -> Lb0
|
||
|
r10.exceptionType = r3
|
||
|
r10.fallback = r3
|
||
|
return
|
||
|
Lb0:
|
||
|
r0 = move-exception
|
||
|
r10.exceptionType = r3
|
||
|
r10.fallback = r3
|
||
|
throw r0
|
||
|
Lb6:
|
||
|
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
|
||
|
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);
|
||
|
StringBuilder sb = new StringBuilder(String.valueOf(valueOf).length() + 16);
|
||
|
sb.append("inputFuture=[");
|
||
|
sb.append(valueOf);
|
||
|
sb.append("], ");
|
||
|
str = sb.toString();
|
||
|
} else {
|
||
|
str = "";
|
||
|
}
|
||
|
if (cls == null || f == null) {
|
||
|
if (pendingToString == null) {
|
||
|
return null;
|
||
|
}
|
||
|
String valueOf2 = String.valueOf(str);
|
||
|
String valueOf3 = String.valueOf(pendingToString);
|
||
|
return valueOf3.length() != 0 ? valueOf2.concat(valueOf3) : new String(valueOf2);
|
||
|
}
|
||
|
String valueOf4 = String.valueOf(cls);
|
||
|
String valueOf5 = String.valueOf(f);
|
||
|
StringBuilder sb2 = new StringBuilder(String.valueOf(str).length() + 29 + String.valueOf(valueOf4).length() + String.valueOf(valueOf5).length());
|
||
|
sb2.append(str);
|
||
|
sb2.append("exceptionType=[");
|
||
|
sb2.append(valueOf4);
|
||
|
sb2.append("], fallback=[");
|
||
|
sb2.append(valueOf5);
|
||
|
sb2.append("]");
|
||
|
return sb2.toString();
|
||
|
}
|
||
|
|
||
|
/* 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: package-private */
|
||
|
/* loaded from: classes2.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
|
||
|
final /* 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 */
|
||
|
final 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 final void setResult(ListenableFuture<? extends V> listenableFuture) {
|
||
|
setFuture(listenableFuture);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* loaded from: classes2.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
|
||
|
final /* 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 */
|
||
|
final V doFallback(Function<? super X, ? extends V> function, X x) throws Exception {
|
||
|
return function.apply(x);
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.util.concurrent.AbstractCatchingFuture
|
||
|
final void setResult(V v) {
|
||
|
set(v);
|
||
|
}
|
||
|
}
|
||
|
}
|