This is an automated email from the ASF dual-hosted git repository.
hepin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko.git
The following commit(s) were added to refs/heads/main by this push:
new 280e1ec892 chore: Deprecate Source#future in javadsl (#2555) (#2593)
280e1ec892 is described below
commit 280e1ec8926e925076928abbb4ff1f0089acd755
Author: He-Pin(kerr) <[email protected]>
AuthorDate: Thu Dec 18 10:52:46 2025 +0800
chore: Deprecate Source#future in javadsl (#2555) (#2593)
* chore: Deprecate Source#future in javadsl
---------
Co-authored-by: PJ Fanning <[email protected]>
---
.../java/org/apache/pekko/stream/javadsl/LazyAndFutureSourcesTest.java | 1 +
stream/src/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 ea98d6eef6..b84fee1685 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
@@ -42,6 +42,7 @@ public class LazyAndFutureSourcesTest extends StreamTest {
// 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<List<String>> 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 9df1019e60..40c41647f0 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
@@ -322,6 +322,7 @@ object Source {
*
* Here for Java interoperability, the normal use from Java should be
[[Source.completionStage]]
*/
+ @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
@@ -337,7 +338,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]