Skip to content

Commit 89bd15c

Browse files
committed
chore: Remove Source#future in javadsl
1 parent 2ecc64c commit 89bd15c

File tree

4 files changed

+5
-20
lines changed

4 files changed

+5
-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-tests/src/test/scala/org/apache/pekko/stream/DslFactoriesConsistencySpec.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class DslFactoriesConsistencySpec extends AnyWordSpec with Matchers {
5656
("apply" -> "fromIterator") ::
5757
("apply" -> "fromFunctions") ::
5858
("apply" -> "fromArray") ::
59+
("future" -> "completionStage") ::
5960
Nil
6061

6162
// format: OFF
@@ -75,6 +76,7 @@ class DslFactoriesConsistencySpec extends AnyWordSpec with Matchers {
7576
(classOf[scala.Function2[_, _, _]], classOf[java.util.function.BiFunction[_, _, _]]) :: // setup
7677
(classOf[scala.Function1[scala.Function1[_, _], _]], classOf[pekko.japi.function.Function2[_, _, _]]) ::
7778
(classOf[scala.concurrent.duration.FiniteDuration], classOf[java.time.Duration]) ::
79+
(classOf[scala.concurrent.Future[_]], classOf[java.util.concurrent.CompletionStage[_]]) ::
7880
(classOf[pekko.stream.scaladsl.Source[_, _]], classOf[pekko.stream.javadsl.Source[_, _]]) ::
7981
(classOf[pekko.stream.scaladsl.Sink[_, _]], classOf[pekko.stream.javadsl.Sink[_, _]]) ::
8082
(classOf[pekko.stream.scaladsl.Flow[_, _, _]], classOf[pekko.stream.javadsl.Flow[_, _, _]]) ::

stream/src/main/mima-filters/2.0.x.backwards.excludes/remove-deprecated-methods.excludes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,4 @@ ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.stream.Acto
202202
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.stream.ActorMaterializer.this")
203203
ProblemFilters.exclude[MissingClassProblem]("org.apache.pekko.stream.impl.SetupStage")
204204
ProblemFilters.exclude[MissingClassProblem]("org.apache.pekko.stream.impl.SetupStage$")
205+
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.stream.javadsl.Source.future")

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._
@@ -316,15 +316,6 @@ object Source {
316316
def failed[T](cause: Throwable): Source[T, NotUsed] =
317317
new Source(scaladsl.Source.failed(cause))
318318

319-
/**
320-
* Emits a single value when the given Scala `Future` is successfully completed and then completes the stream.
321-
* The stream fails if the `Future` is completed with a failure.
322-
*
323-
* Here for Java interoperability, the normal use from Java should be [[Source.completionStage]]
324-
*/
325-
def future[T](futureElement: Future[T]): Source[T, NotUsed] =
326-
scaladsl.Source.future(futureElement).asJava
327-
328319
/**
329320
* Never emits any elements, never completes and never fails.
330321
* This stream could be useful in tests.
@@ -337,7 +328,7 @@ object Source {
337328
* If the `CompletionStage` is completed with a failure the stream is failed.
338329
*/
339330
def completionStage[T](completionStage: CompletionStage[T]): Source[T, NotUsed] =
340-
future(completionStage.asScala)
331+
new Source(scaladsl.Source.future(completionStage.asScala))
341332

342333
/**
343334
* 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)