aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Berlin <sberlin@gmail.com>2015-04-23 16:07:44 -0400
committerSam Berlin <sberlin@gmail.com>2015-04-23 16:07:44 -0400
commit57e87fedb5af85511af7247d2e58781c176e2333 (patch)
treefdf0b8637f190053b53876fd2ee8fd52af4211ba
parent25b0a46ada0f8a5a1c3b3dad109ff2b0b3bb12f4 (diff)
parent5be3e95b938fde9b4276a1d2a31ec0767d365038 (diff)
downloadguice-57e87fedb5af85511af7247d2e58781c176e2333.tar.gz
Merge pull request #919 from google/moe_writing_branch_from_156c8cc762fab971efb727c7ab107fa243be2fc9
Merge internal changes
-rw-r--r--core/src/com/google/inject/internal/CycleDetectingLock.java18
-rw-r--r--extensions/service/src/com/google/inject/service/AsyncService.java9
-rw-r--r--pom.xml13
3 files changed, 21 insertions, 19 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>() {
diff --git a/pom.xml b/pom.xml
index 70d9fa45..a34a9d0b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -443,7 +443,7 @@ See the Apache License Version 2.0 for the specific language governing permissio
</modules>
<!-- Disable doclint under JDK 8 -->
<reporting>
- <plugins>
+ <plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
@@ -466,16 +466,5 @@ See the Apache License Version 2.0 for the specific language governing permissio
</build>
</profile>
</profiles>
-
<!-- TODO(cgruber): Update the google parent pom or migrate to sonatype's -->
- <!-- TODO(cgruber): Comment out dagger-adapter from extensions/pom.xml if v2 is not released. -->
- <repositories>
- <repository>
- <id>sonatype-nexus-snapshots</id>
- <name>Sonatype Nexus Snapshots</name>
- <url>https://oss.sonatype.org/content/repositories/snapshots</url>
- <releases><enabled>false</enabled></releases>
- <snapshots><enabled>true</enabled></snapshots>
- </repository>
- </repositories>
</project>