Skip to content

Commit a4f982e

Browse files
He-Pinpjfanning
andauthored
chore: Deprecate Source#future in javadsl (#2555)
* chore: Deprecate Source#future in javadsl * Update stream/src/main/scala/org/apache/pekko/stream/javadsl/Source.scala Co-authored-by: PJ Fanning <[email protected]> --------- Co-authored-by: PJ Fanning <[email protected]>
1 parent e68bf0a commit a4f982e

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
@@ -43,6 +43,7 @@ public LazyAndFutureSourcesTest() {
4343
// note these are minimal happy path tests to cover API, more thorough tests are on the Scala side
4444

4545
@Test
46+
@SuppressWarnings("deprecation")
4647
public void future() throws Exception {
4748
CompletionStage<List<String>> result =
4849
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
@@ -391,6 +391,7 @@ object Source {
391391
*
392392
* Here for Java interoperability, the normal use from Java should be [[Source.completionStage]]
393393
*/
394+
@deprecated("Use 'Source.completionStage' or 'scaladsl.Source.future' instead", "1.5.0")
394395
def future[T](futureElement: Future[T]): Source[T, NotUsed] =
395396
scaladsl.Source.future(futureElement).asJava
396397

@@ -406,7 +407,7 @@ object Source {
406407
* If the `CompletionStage` is completed with a failure the stream is failed.
407408
*/
408409
def completionStage[T](completionStage: CompletionStage[T]): Source[T, NotUsed] =
409-
future(completionStage.asScala)
410+
new Source(scaladsl.Source.future(completionStage.asScala))
410411

411412
/**
412413
* 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)