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

Commit

Permalink
Merge pull request #1260 from spotify/future-catching-deprecation
Browse files Browse the repository at this point in the history
remove usage of deprecated Futures.catching from Guava
  • Loading branch information
mattnworb authored Dec 13, 2018
2 parents 712c817 + 8a04a3b commit b8ea023
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 b8ea023

Please sign in to comment.