Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Commit

Permalink
remove usage of deprecated Futures.catching from Guava
Browse files Browse the repository at this point in the history
The overload of this method that does not take an Executor as an
argument is removed from Guava starting in release 26.0.

For anyone using helios-testing in a project that uses Guava >= 26.0,
this code in helios-testing causes NoSuchMethodErrors at runtime.

This is related to #1257 which I think missing this `Futures` method.
  • Loading branch information
mattnworb committed Dec 13, 2018
1 parent 712c817 commit 8a04a3b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import com.fasterxml.jackson.core.type.TypeReference;
import com.google.common.base.CharMatcher;
import com.google.common.base.Charsets;
import com.google.common.base.Function;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
Expand All @@ -59,6 +58,7 @@
import com.google.common.io.Files;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.Service;
import com.spotify.docker.client.DefaultDockerClient;
import com.spotify.docker.client.DockerCertificates;
Expand Down Expand Up @@ -1019,12 +1019,8 @@ public DeploymentGroupStatus call() throws Exception {

protected <T> T getOrNull(final ListenableFuture<T> future)
throws ExecutionException, InterruptedException {
return Futures.catching(future, Exception.class, new Function<Exception, T>() {
@Override
public T apply(final Exception ex) {
return null;
}
}).get();
return Futures.catching(future, Exception.class, ex -> null, MoreExecutors.directExecutor())
.get();
}

protected static void removeContainer(final DockerClient dockerClient, final String containerId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import static java.util.Collections.singletonList;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
Expand All @@ -34,6 +33,7 @@
import com.google.common.net.HostAndPort;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import com.spotify.docker.client.DefaultDockerClient;
import com.spotify.docker.client.DockerClient;
import com.spotify.docker.client.DockerHost;
Expand Down Expand Up @@ -592,12 +592,8 @@ public Boolean call() throws Exception {

private <T> T getOrNull(final ListenableFuture<T> future)
throws ExecutionException, InterruptedException {
return Futures.catching(future, Exception.class, new Function<Exception, T>() {
@Override
public T apply(final Exception ex) {
return null;
}
}).get();
return Futures.catching(future, Exception.class, ex -> null, MoreExecutors.directExecutor())
.get();
}

/**
Expand Down

0 comments on commit 8a04a3b

Please sign in to comment.