This is an automated email from the ASF dual-hosted git repository. hepin pushed a commit to branch dropFutureSourceInJava in repository https://gitbox.apache.org/repos/asf/pekko.git
commit fa68d01eab46cd60df4e8c5fb133ea0ced500ed9 Author: He-Pin <[email protected]> AuthorDate: Sat Dec 6 17:46:34 2025 +0800 chore: Remove Source#future in javadsl --- .../pekko/stream/javadsl/LazyAndFutureSourcesTest.java | 8 -------- .../main/scala/org/apache/pekko/stream/javadsl/Source.scala | 13 ++----------- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/stream-tests/src/test/java/org/apache/pekko/stream/javadsl/LazyAndFutureSourcesTest.java b/stream-tests/src/test/java/org/apache/pekko/stream/javadsl/LazyAndFutureSourcesTest.java index ea98d6eef6..68b30084ac 100644 --- a/stream-tests/src/test/java/org/apache/pekko/stream/javadsl/LazyAndFutureSourcesTest.java +++ b/stream-tests/src/test/java/org/apache/pekko/stream/javadsl/LazyAndFutureSourcesTest.java @@ -41,14 +41,6 @@ public class LazyAndFutureSourcesTest extends StreamTest { // note these are minimal happy path tests to cover API, more thorough tests are on the Scala side - @Test - public void future() throws Exception { - CompletionStage<List<String>> result = - Source.future(Future.successful("one")).runWith(Sink.seq(), system); - - assertEquals(Arrays.asList("one"), result.toCompletableFuture().get(3, TimeUnit.SECONDS)); - } - @Test public void completionStage() throws Exception { CompletionStage<String> one = CompletableFuture.completedFuture("one"); diff --git a/stream/src/main/scala/org/apache/pekko/stream/javadsl/Source.scala b/stream/src/main/scala/org/apache/pekko/stream/javadsl/Source.scala index 89bef8f91f..f57d85f1f3 100755 --- a/stream/src/main/scala/org/apache/pekko/stream/javadsl/Source.scala +++ b/stream/src/main/scala/org/apache/pekko/stream/javadsl/Source.scala @@ -20,7 +20,7 @@ import java.util.concurrent.{ CompletableFuture, CompletionStage } import scala.annotation.{ nowarn, varargs } import scala.annotation.unchecked.uncheckedVariance import scala.collection.immutable -import scala.concurrent.{ Future, Promise } +import scala.concurrent.Promise import scala.concurrent.ExecutionContext import scala.jdk.CollectionConverters._ import scala.jdk.DurationConverters._ @@ -311,15 +311,6 @@ object Source { def failed[T](cause: Throwable): Source[T, NotUsed] = new Source(scaladsl.Source.failed(cause)) - /** - * Emits a single value when the given Scala `Future` is successfully completed and then completes the stream. - * The stream fails if the `Future` is completed with a failure. - * - * Here for Java interoperability, the normal use from Java should be [[Source.completionStage]] - */ - def future[T](futureElement: Future[T]): Source[T, NotUsed] = - scaladsl.Source.future(futureElement).asJava - /** * Never emits any elements, never completes and never fails. * This stream could be useful in tests. @@ -332,7 +323,7 @@ object Source { * If the `CompletionStage` is completed with a failure the stream is failed. */ def completionStage[T](completionStage: CompletionStage[T]): Source[T, NotUsed] = - future(completionStage.asScala) + new Source(scaladsl.Source.future(completionStage.asScala)) /** * Turn a `CompletionStage[Source]` into a source that will emit the values of the source when the future completes successfully. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
