materialized value of Flow.lazyInit must be a Future #24670 (#24685)

* change materialized value of LazyFlow from [M] to Future[Option[M]]

* remove whitespace

* improve docu

* restore old Flow.lazyInit method and add new Flow.lazyInitAsync method

* fix deprecation messages

* add 2.5.11.backwards.excludes because of changed LazyFlow constructor signature

* check switching behaviour

* apply formatting

* improve deprecation message; improve null safety

* prevent premature stage completion by setting keepGoing

* deprecate Sink.lazyInit; add Sink.lazyInitAsync

* apply formatting

* add ProblemFilter.exclude for changed LazySink.this

* Update Sink.scala

* Update Sink.scala

* Update Flow.scala

* Update Flow.scala
This commit is contained in:
Stefan Wachter 2018-03-19 14:42:37 +01:00 committed by Konrad `ktoso` Malawski
parent 770b3a3474
commit 3db145643a
12 changed files with 454 additions and 383 deletions

View file

@ -978,16 +978,9 @@ public class FlowTest extends StreamTest {
public void mustBeAbleToUseLazyInit() throws Exception {
final CompletionStage<Flow<Integer, Integer, NotUsed>> future = new CompletableFuture<Flow<Integer, Integer, NotUsed>>();
future.toCompletableFuture().complete(Flow.fromFunction((id) -> id));
Creator<NotUsed> ignoreFunction = new Creator<NotUsed>() {
@Override
public NotUsed create() throws Exception {
return NotUsed.getInstance();
}
};
Integer result =
Source.range(1, 10)
.via(Flow.lazyInit((i) -> future, ignoreFunction))
.via(Flow.lazyInitAsync(() -> future))
.runWith(Sink.<Integer>head(), materializer)
.toCompletableFuture().get(3, TimeUnit.SECONDS);