Skip to content

Commit

Permalink
TorDiscovery: Bugfix. Guava now returns immutable lists from Futures …
Browse files Browse the repository at this point in the history
…methods (annoying).
  • Loading branch information
mikehearn committed Apr 27, 2014
1 parent 9cfb420 commit d39cc88
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

import static java.util.Collections.singleton;

/**
* <p>Supports peer discovery through Tor.</p>
*
Expand Down Expand Up @@ -160,11 +162,10 @@ public Circuit call() throws Exception {
}
}

List<Circuit> circuits;
try {
circuits = Futures.successfulAsList(circuitFutures).get();
List<Circuit> circuits = new ArrayList<Circuit>(Futures.successfulAsList(circuitFutures).get());
// Any failures will result in null entries. Remove them.
circuits.removeAll(Collections.singleton(null));
circuits.removeAll(singleton(null));
return circuits;
} catch (ExecutionException e) {
// Cannot happen, successfulAsList accepts failures
Expand Down Expand Up @@ -199,9 +200,9 @@ public Lookup call() throws Exception {
}

try {
List<Lookup> lookups = Futures.successfulAsList(lookupFutures).get();
List<Lookup> lookups = new ArrayList<Lookup>(Futures.successfulAsList(lookupFutures).get());
// Any failures will result in null entries. Remove them.
lookups.removeAll(Collections.singleton(null));
lookups.removeAll(singleton(null));

// Use a map to enforce one result per exit node
// TODO: randomize result selection better
Expand Down

0 comments on commit d39cc88

Please sign in to comment.