From d8a1afb178de131cbc05d05ee8b33c0065727425 Mon Sep 17 00:00:00 2001 From: He-Pin Date: Sat, 6 Dec 2025 18:05:24 +0800 Subject: [PATCH 1/2] chore: Deprecate Source#future in javadsl --- .../apache/pekko/stream/javadsl/LazyAndFutureSourcesTest.java | 1 + .../main/scala/org/apache/pekko/stream/javadsl/Source.scala | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) 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 f379b49ce00..958948ea94a 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 @@ -43,6 +43,7 @@ public LazyAndFutureSourcesTest() { // note these are minimal happy path tests to cover API, more thorough tests are on the Scala side @Test + @SuppressWarnings("deprecation") public void future() throws Exception { CompletionStage> result = Source.future(Future.successful("one")).runWith(Sink.seq(), system); 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 5cc54012190..fada6b0a438 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 @@ -391,6 +391,7 @@ object Source { * * Here for Java interoperability, the normal use from Java should be [[Source.completionStage]] */ + @deprecated("Use 'Source.completionStage' instead", "Pekko 1.5.0") def future[T](futureElement: Future[T]): Source[T, NotUsed] = scaladsl.Source.future(futureElement).asJava @@ -406,7 +407,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. From 15ac4ede729996f596f8a9e1be35b835538db170 Mon Sep 17 00:00:00 2001 From: "He-Pin(kerr)" Date: Wed, 17 Dec 2025 15:32:33 +0800 Subject: [PATCH 2/2] Update stream/src/main/scala/org/apache/pekko/stream/javadsl/Source.scala Co-authored-by: PJ Fanning --- .../src/main/scala/org/apache/pekko/stream/javadsl/Source.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 fada6b0a438..94fdf248e25 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 @@ -391,7 +391,7 @@ object Source { * * Here for Java interoperability, the normal use from Java should be [[Source.completionStage]] */ - @deprecated("Use 'Source.completionStage' instead", "Pekko 1.5.0") + @deprecated("Use 'Source.completionStage' or 'scaladsl.Source.future' instead", "1.5.0") def future[T](futureElement: Future[T]): Source[T, NotUsed] = scaladsl.Source.future(futureElement).asJava