diff --git a/android/guava-tests/test/com/google/common/util/concurrent/FluentFutureTest.java b/android/guava-tests/test/com/google/common/util/concurrent/FluentFutureTest.java index 6c66c46b9289..73fbcddb91fd 100644 --- a/android/guava-tests/test/com/google/common/util/concurrent/FluentFutureTest.java +++ b/android/guava-tests/test/com/google/common/util/concurrent/FluentFutureTest.java @@ -44,6 +44,11 @@ public void testFromFluentFuture() { assertThat(FluentFuture.from(f)).isSameAs(f); } + public void testFromFluentFuturePassingAsNonFluent() { + ListenableFuture f = FluentFuture.from(SettableFuture.create()); + assertThat(FluentFuture.from(f)).isSameAs(f); + } + public void testFromNonFluentFuture() throws Exception { ListenableFuture f = new SimpleForwardingListenableFuture(immediateFuture("a")) {}; diff --git a/android/guava/src/com/google/common/util/concurrent/FluentFuture.java b/android/guava/src/com/google/common/util/concurrent/FluentFuture.java index c7d795565ad1..39c3ed63f9e2 100644 --- a/android/guava/src/com/google/common/util/concurrent/FluentFuture.java +++ b/android/guava/src/com/google/common/util/concurrent/FluentFuture.java @@ -14,6 +14,8 @@ package com.google.common.util.concurrent; +import static com.google.common.base.Preconditions.checkNotNull; + import com.google.common.annotations.Beta; import com.google.common.annotations.GwtCompatible; import com.google.common.annotations.GwtIncompatible; @@ -126,6 +128,17 @@ public static FluentFuture from(ListenableFuture future) { : new ForwardingFluentFuture(future); } + /** + * Simply returns its argument. + * + * @deprecated no need to use this + * @since NEXT + */ + @Deprecated + public static FluentFuture from(FluentFuture future) { + return checkNotNull(future); + } + /** * Returns a {@code Future} whose result is taken from this {@code Future} or, if this {@code * Future} fails with the given {@code exceptionType}, from the result provided by the {@code diff --git a/guava-gwt/test/com/google/common/util/concurrent/FluentFutureTest_gwt.java b/guava-gwt/test/com/google/common/util/concurrent/FluentFutureTest_gwt.java index 865d749fbb47..3fca40f6a667 100644 --- a/guava-gwt/test/com/google/common/util/concurrent/FluentFutureTest_gwt.java +++ b/guava-gwt/test/com/google/common/util/concurrent/FluentFutureTest_gwt.java @@ -38,6 +38,11 @@ public void testFromFluentFuture() throws Exception { testCase.testFromFluentFuture(); } +public void testFromFluentFuturePassingAsNonFluent() throws Exception { + com.google.common.util.concurrent.FluentFutureTest testCase = new com.google.common.util.concurrent.FluentFutureTest(); + testCase.testFromFluentFuturePassingAsNonFluent(); +} + public void testFromNonFluentFuture() throws Exception { com.google.common.util.concurrent.FluentFutureTest testCase = new com.google.common.util.concurrent.FluentFutureTest(); testCase.testFromNonFluentFuture(); diff --git a/guava-tests/test/com/google/common/util/concurrent/FluentFutureTest.java b/guava-tests/test/com/google/common/util/concurrent/FluentFutureTest.java index 6c66c46b9289..73fbcddb91fd 100644 --- a/guava-tests/test/com/google/common/util/concurrent/FluentFutureTest.java +++ b/guava-tests/test/com/google/common/util/concurrent/FluentFutureTest.java @@ -44,6 +44,11 @@ public void testFromFluentFuture() { assertThat(FluentFuture.from(f)).isSameAs(f); } + public void testFromFluentFuturePassingAsNonFluent() { + ListenableFuture f = FluentFuture.from(SettableFuture.create()); + assertThat(FluentFuture.from(f)).isSameAs(f); + } + public void testFromNonFluentFuture() throws Exception { ListenableFuture f = new SimpleForwardingListenableFuture(immediateFuture("a")) {}; diff --git a/guava/src/com/google/common/util/concurrent/FluentFuture.java b/guava/src/com/google/common/util/concurrent/FluentFuture.java index c7d795565ad1..39c3ed63f9e2 100644 --- a/guava/src/com/google/common/util/concurrent/FluentFuture.java +++ b/guava/src/com/google/common/util/concurrent/FluentFuture.java @@ -14,6 +14,8 @@ package com.google.common.util.concurrent; +import static com.google.common.base.Preconditions.checkNotNull; + import com.google.common.annotations.Beta; import com.google.common.annotations.GwtCompatible; import com.google.common.annotations.GwtIncompatible; @@ -126,6 +128,17 @@ public static FluentFuture from(ListenableFuture future) { : new ForwardingFluentFuture(future); } + /** + * Simply returns its argument. + * + * @deprecated no need to use this + * @since NEXT + */ + @Deprecated + public static FluentFuture from(FluentFuture future) { + return checkNotNull(future); + } + /** * Returns a {@code Future} whose result is taken from this {@code Future} or, if this {@code * Future} fails with the given {@code exceptionType}, from the result provided by the {@code