CrackMe.apk
Download file
package com.google.common.util.concurrent;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.UnmodifiableIterator;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.CheckForNull;
@ElementTypesAreNonnullByDefault
abstract class AggregateFuture<InputT, OutputT> extends AggregateFutureState<OutputT> {
private static final Logger logger = Logger.getLogger(AggregateFuture.class.getName());
private final boolean allMustSucceed;
private final boolean collectsValues;
/* access modifiers changed from: private */
@CheckForNull
public ImmutableCollection<? extends ListenableFuture<? extends InputT>> futures;
enum ReleaseResourcesReason {
OUTPUT_FUTURE_DONE,
ALL_INPUT_FUTURES_PROCESSED
}
/* access modifiers changed from: package-private */
public abstract void collectOneValue(int i, @ParametricNullness InputT inputt);
/* access modifiers changed from: package-private */
public abstract void handleAllCompleted();
AggregateFuture(ImmutableCollection<? extends ListenableFuture<? extends InputT>> immutableCollection, boolean z, boolean z2) {
super(immutableCollection.size());
this.futures = (ImmutableCollection) Preconditions.checkNotNull(immutableCollection);
this.allMustSucceed = z;
this.collectsValues = z2;
}
/* access modifiers changed from: protected */
public final void afterDone() {
super.afterDone();
ImmutableCollection<? extends ListenableFuture<? extends InputT>> immutableCollection = this.futures;
releaseResources(ReleaseResourcesReason.OUTPUT_FUTURE_DONE);
if (isCancelled() && (immutableCollection != null)) {
boolean wasInterrupted = wasInterrupted();
UnmodifiableIterator<? extends ListenableFuture<? extends InputT>> it = immutableCollection.iterator();
while (it.hasNext()) {
((Future) it.next()).cancel(wasInterrupted);
}
}
}
/* access modifiers changed from: protected */
@CheckForNull
public final String pendingToString() {
ImmutableCollection<? extends ListenableFuture<? extends InputT>> immutableCollection = this.futures;
if (immutableCollection == null) {
return super.pendingToString();
}
String valueOf = String.valueOf(immutableCollection);
StringBuilder sb = new StringBuilder(String.valueOf(valueOf).length() + 8);
sb.append("futures=");
sb.append(valueOf);
return sb.toString();
}
/* access modifiers changed from: package-private */
public final void init() {
Objects.requireNonNull(this.futures);
if (this.futures.isEmpty()) {
handleAllCompleted();
} else if (this.allMustSucceed) {
final int i = 0;
UnmodifiableIterator<? extends ListenableFuture<? extends InputT>> it = this.futures.iterator();
while (it.hasNext()) {
final ListenableFuture listenableFuture = (ListenableFuture) it.next();
listenableFuture.addListener(new Runnable() {
public void run() {
try {
if (listenableFuture.isCancelled()) {
ImmutableCollection unused = AggregateFuture.this.futures = null;
AggregateFuture.this.cancel(false);
} else {
AggregateFuture.this.collectValueFromNonCancelledFuture(i, listenableFuture);
}
} finally {
AggregateFuture.this.decrementCountAndMaybeComplete((ImmutableCollection) null);
}
}
}, MoreExecutors.directExecutor());
i++;
}
} else {
final ImmutableCollection<? extends ListenableFuture<? extends InputT>> immutableCollection = this.collectsValues ? this.futures : null;
AnonymousClass2 r1 = new Runnable() {
public void run() {
AggregateFuture.this.decrementCountAndMaybeComplete(immutableCollection);
}
};
UnmodifiableIterator<? extends ListenableFuture<? extends InputT>> it2 = this.futures.iterator();
while (it2.hasNext()) {
((ListenableFuture) it2.next()).addListener(r1, MoreExecutors.directExecutor());
}
}
}
private void handleException(Throwable th) {
Preconditions.checkNotNull(th);
if (this.allMustSucceed && !setException(th) && addCausalChain(getOrInitSeenExceptions(), th)) {
log(th);
} else if (th instanceof Error) {
log(th);
}
}
private static void log(Throwable th) {
logger.log(Level.SEVERE, th instanceof Error ? "Input Future failed with Error" : "Got more than one input Future failure. Logging failures after the first", th);
}
/* access modifiers changed from: package-private */
public final void addInitialException(Set<Throwable> set) {
Preconditions.checkNotNull(set);
if (!isCancelled()) {
Throwable tryInternalFastPathGetFailure = tryInternalFastPathGetFailure();
Objects.requireNonNull(tryInternalFastPathGetFailure);
Throwable th = tryInternalFastPathGetFailure;
addCausalChain(set, tryInternalFastPathGetFailure);
}
}
/* access modifiers changed from: private */
public void collectValueFromNonCancelledFuture(int i, Future<? extends InputT> future) {
try {
collectOneValue(i, Futures.getDone(future));
} catch (ExecutionException e) {
handleException(e.getCause());
} catch (Throwable th) {
handleException(th);
}
}
/* access modifiers changed from: private */
public void decrementCountAndMaybeComplete(@CheckForNull ImmutableCollection<? extends Future<? extends InputT>> immutableCollection) {
int decrementRemainingAndGet = decrementRemainingAndGet();
Preconditions.checkState(decrementRemainingAndGet >= 0, "Less than 0 remaining futures");
if (decrementRemainingAndGet == 0) {
processCompleted(immutableCollection);
}
}
private void processCompleted(@CheckForNull ImmutableCollection<? extends Future<? extends InputT>> immutableCollection) {
if (immutableCollection != null) {
int i = 0;
UnmodifiableIterator<? extends Future<? extends InputT>> it = immutableCollection.iterator();
while (it.hasNext()) {
Future future = (Future) it.next();
if (!future.isCancelled()) {
collectValueFromNonCancelledFuture(i, future);
}
i++;
}
}
clearSeenExceptions();
handleAllCompleted();
releaseResources(ReleaseResourcesReason.ALL_INPUT_FUTURES_PROCESSED);
}
/* access modifiers changed from: package-private */
public void releaseResources(ReleaseResourcesReason releaseResourcesReason) {
Preconditions.checkNotNull(releaseResourcesReason);
this.futures = null;
}
private static boolean addCausalChain(Set<Throwable> set, Throwable th) {
while (th != null) {
if (!set.add(th)) {
return false;
}
th = th.getCause();
}
return true;
}
}
Download file