Skip to content

Commit

Permalink
Merge pull request #20 from spotify/krka/joined-results-fix
Browse files Browse the repository at this point in the history
Fix bug where compiler can't figure out how to call FuturesExtra.join
  • Loading branch information
spkrka committed Dec 9, 2015
2 parents 9a0e959 + bc501e7 commit d7a12d5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public static <T> CompletionStage<T> exceptionallyCompose(
* @param stage a {@link CompletionStage}.
* @throws IllegalStateException if the stage is not completed.
*/
public static void checkCompleted(CompletionStage<?> stage) {
public static <T> void checkCompleted(CompletionStage<T> stage) {
if (!stage.toCompletableFuture().isDone()) {
throw new IllegalStateException("future was not completed");
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/spotify/futures/FuturesExtra.java
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ private static <Z> ListenableFuture<Z> transform(final List<ListenableFuture<?>>
* the join is accessed.</p>
* @see #join(ListenableFuture...)
*/
public static ListenableFuture<JoinedResults> join(List<ListenableFuture<?>> inputs) {
public static <T> ListenableFuture<JoinedResults> join(List<ListenableFuture<T>> inputs) {
return Futures.transform(Futures.allAsList(inputs), new JoinedResults.Transform(inputs));
}

Expand Down Expand Up @@ -645,7 +645,7 @@ public static <I, O> ListenableFuture<O> asyncTransform(
* @param future the future.
* @throws IllegalStateException if the future is not completed.
*/
public static void checkCompleted(ListenableFuture<?> future) {
public static <T> void checkCompleted(ListenableFuture<T> future) {
if (!future.isDone()) {
throw new IllegalStateException("future was not completed");
}
Expand All @@ -671,7 +671,7 @@ public static <T> T getCompleted(ListenableFuture<T> future) {
* @return the exception of a future or null if no exception was thrown
* @throws IllegalStateException if the future is not completed.
*/
public static Throwable getException(ListenableFuture<?> future) {
public static <T> Throwable getException(ListenableFuture<T> future) {
checkCompleted(future);
try {
Uninterruptibles.getUninterruptibly(future);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/spotify/futures/JoinedResults.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ public <T> T get(ListenableFuture<T> future) {
return t;
}

static class Transform implements Function<List<Object>, JoinedResults> {
private final List<ListenableFuture<?>> futures;
public Transform(List<ListenableFuture<?>> list) {
static class Transform<T> implements Function<List<Object>, JoinedResults> {
private final List<ListenableFuture<T>> futures;
public Transform(List<ListenableFuture<T>> list) {
futures = ImmutableList.copyOf(list);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void testMixedTypes() throws Exception {
public void testWithList() throws Exception {
ListenableFuture<String> futureA = Futures.immediateFuture("a");
ListenableFuture<String> futureB = Futures.immediateFuture("b");
List<ListenableFuture<?>> list = Arrays.<ListenableFuture<?>>asList(futureA, futureB);
List<ListenableFuture<String>> list = Arrays.asList(futureA, futureB);
JoinedResults joined = FuturesExtra.join(list).get();
assertEquals("a", joined.get(futureA));
assertEquals("b", joined.get(futureB));
Expand Down

0 comments on commit d7a12d5

Please sign in to comment.