Skip to content

Commit 1e3b98f

Browse files
committed
chore: Remove Source#future in javadsl
1 parent d5f7d35 commit 1e3b98f

File tree

2 files changed

+2
-20
lines changed

2 files changed

+2
-20
lines changed

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.apache.pekko.testkit.PekkoSpec;
2828
import org.junit.ClassRule;
2929
import org.junit.Test;
30-
import scala.concurrent.Future;
3130

3231
public class LazyAndFutureSourcesTest extends StreamTest {
3332

@@ -41,14 +40,6 @@ public LazyAndFutureSourcesTest() {
4140

4241
// note these are minimal happy path tests to cover API, more thorough tests are on the Scala side
4342

44-
@Test
45-
public void future() throws Exception {
46-
CompletionStage<List<String>> result =
47-
Source.future(Future.successful("one")).runWith(Sink.seq(), system);
48-
49-
assertEquals(Arrays.asList("one"), result.toCompletableFuture().get(3, TimeUnit.SECONDS));
50-
}
51-
5243
@Test
5344
public void completionStage() throws Exception {
5445
CompletionStage<String> one = CompletableFuture.completedFuture("one");

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

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import java.util.concurrent.{ CompletableFuture, CompletionStage }
2020
import scala.annotation.{ nowarn, varargs }
2121
import scala.annotation.unchecked.uncheckedVariance
2222
import scala.collection.immutable
23-
import scala.concurrent.{ Future, Promise }
23+
import scala.concurrent.Promise
2424
import scala.concurrent.ExecutionContext
2525
import scala.jdk.CollectionConverters._
2626
import scala.jdk.DurationConverters._
@@ -311,15 +311,6 @@ object Source {
311311
def failed[T](cause: Throwable): Source[T, NotUsed] =
312312
new Source(scaladsl.Source.failed(cause))
313313

314-
/**
315-
* Emits a single value when the given Scala `Future` is successfully completed and then completes the stream.
316-
* The stream fails if the `Future` is completed with a failure.
317-
*
318-
* Here for Java interoperability, the normal use from Java should be [[Source.completionStage]]
319-
*/
320-
def future[T](futureElement: Future[T]): Source[T, NotUsed] =
321-
scaladsl.Source.future(futureElement).asJava
322-
323314
/**
324315
* Never emits any elements, never completes and never fails.
325316
* This stream could be useful in tests.
@@ -332,7 +323,7 @@ object Source {
332323
* If the `CompletionStage` is completed with a failure the stream is failed.
333324
*/
334325
def completionStage[T](completionStage: CompletionStage[T]): Source[T, NotUsed] =
335-
future(completionStage.asScala)
326+
new Source(scaladsl.Source.future(completionStage.asScala))
336327

337328
/**
338329
* 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)