Skip to content

Commit 280e1ec

Browse files
He-Pinpjfanning
andauthored
chore: Deprecate Source#future in javadsl (#2555) (#2593)
* chore: Deprecate Source#future in javadsl --------- Co-authored-by: PJ Fanning <[email protected]>
1 parent 306cd43 commit 280e1ec

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

stream-tests/src/test/java/org/apache/pekko/stream/javadsl/LazyAndFutureSourcesTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public LazyAndFutureSourcesTest() {
4242
// note these are minimal happy path tests to cover API, more thorough tests are on the Scala side
4343

4444
@Test
45+
@SuppressWarnings("deprecation")
4546
public void future() throws Exception {
4647
CompletionStage<List<String>> result =
4748
Source.future(Future.successful("one")).runWith(Sink.seq(), system);

stream/src/main/scala/org/apache/pekko/stream/javadsl/Source.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ object Source {
322322
*
323323
* Here for Java interoperability, the normal use from Java should be [[Source.completionStage]]
324324
*/
325+
@deprecated("Use 'Source.completionStage' or 'scaladsl.Source.future' instead", "1.5.0")
325326
def future[T](futureElement: Future[T]): Source[T, NotUsed] =
326327
scaladsl.Source.future(futureElement).asJava
327328

@@ -337,7 +338,7 @@ object Source {
337338
* If the `CompletionStage` is completed with a failure the stream is failed.
338339
*/
339340
def completionStage[T](completionStage: CompletionStage[T]): Source[T, NotUsed] =
340-
future(completionStage.asScala)
341+
new Source(scaladsl.Source.future(completionStage.asScala))
341342

342343
/**
343344
* Turn a `CompletionStage[Source]` into a source that will emit the values of the source when the future completes successfully.

0 commit comments

Comments
 (0)