aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcgdecker <cgdecker@google.com>2015-04-21 13:53:15 -0700
committerSam Berlin <sameb@google.com>2015-04-23 15:25:43 -0400
commit1a30c07469f896097c1311e039ca3066873f5db9 (patch)
tree054159015c276496a03963aae51f2c08270752ca
parent25b0a46ada0f8a5a1c3b3dad109ff2b0b3bb12f4 (diff)
downloadguice-1a30c07469f896097c1311e039ca3066873f5db9.tar.gz
Also fix usages of a couple of @Beta APIs.
------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=91720693
-rw-r--r--core/src/com/google/inject/internal/CycleDetectingLock.java18
-rw-r--r--extensions/service/src/com/google/inject/service/AsyncService.java9
2 files changed, 20 insertions, 7 deletions
diff --git a/core/src/com/google/inject/internal/CycleDetectingLock.java b/core/src/com/google/inject/internal/CycleDetectingLock.java
index 9c46c44e..690b1510 100644
--- a/core/src/com/google/inject/internal/CycleDetectingLock.java
+++ b/core/src/com/google/inject/internal/CycleDetectingLock.java
@@ -1,14 +1,18 @@
package com.google.inject.internal;
import com.google.common.base.Preconditions;
+import com.google.common.base.Supplier;
+import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ImmutableListMultimap;
+import com.google.common.collect.LinkedHashMultimap;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
-import com.google.common.collect.MultimapBuilder;
+import com.google.common.collect.Multimaps;
import java.util.Collection;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.locks.Lock;
@@ -103,7 +107,7 @@ interface CycleDetectingLock<ID> {
* Guarded by {@code this}.
*/
private final Multimap<Long, ReentrantCycleDetectingLock> locksOwnedByThread =
- MultimapBuilder.linkedHashKeys().linkedHashSetValues().build();
+ LinkedHashMultimap.create();
/**
* Creates new lock within this factory context. We can guarantee that locks created by
@@ -234,8 +238,14 @@ interface CycleDetectingLock<ID> {
return ImmutableListMultimap.of();
}
- ListMultimap<Long, ID> potentialLocksCycle =
- MultimapBuilder.linkedHashKeys().arrayListValues().build();
+ ListMultimap<Long, ID> potentialLocksCycle = Multimaps.newListMultimap(
+ new LinkedHashMap<Long, Collection<ID>>(),
+ new Supplier<List<ID>>() {
+ @Override
+ public List<ID> get() {
+ return Lists.newArrayList();
+ }
+ });
// lock that is a part of a potential locks cycle, starts with current lock
ReentrantCycleDetectingLock lockOwnerWaitingOn = this;
// try to find a dependency path between lock's owner thread and a current thread
diff --git a/extensions/service/src/com/google/inject/service/AsyncService.java b/extensions/service/src/com/google/inject/service/AsyncService.java
index 8efef129..fe0c3a51 100644
--- a/extensions/service/src/com/google/inject/service/AsyncService.java
+++ b/extensions/service/src/com/google/inject/service/AsyncService.java
@@ -17,7 +17,6 @@
package com.google.inject.service;
import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.Runnables;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
@@ -31,6 +30,10 @@ import java.util.concurrent.FutureTask;
* @author dhanji@gmail.com (Dhanji R. Prasanna)
*/
public abstract class AsyncService implements Service {
+ private static final Runnable DO_NOTHING = new Runnable() {
+ @Override public void run() {}
+ };
+
private final ExecutorService executor;
private volatile State state;
@@ -45,7 +48,7 @@ public abstract class AsyncService implements Service {
// Starts are idempotent.
if (state == State.STARTED) {
- return new FutureTask<State>(Runnables.doNothing(), State.STARTED);
+ return new FutureTask<State>(DO_NOTHING, State.STARTED);
}
return executor.submit(new Callable<State>() {
@@ -70,7 +73,7 @@ public abstract class AsyncService implements Service {
// Likewise, stops are idempotent.
if (state == State.STOPPED) {
- return new FutureTask<State>(Runnables.doNothing(), State.STOPPED);
+ return new FutureTask<State>(DO_NOTHING, State.STOPPED);
}
return executor.submit(new Callable<State>() {