Skip to content

Commit

Permalink
Fix ThingUpdaterTest.
Browse files Browse the repository at this point in the history
Signed-off-by: Yufei Cai <yufei.cai@bosch.io>
  • Loading branch information
yufei-cai committed Apr 8, 2022
1 parent a5ba29a commit 4fc79a7
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -298,21 +298,20 @@ private FSM.State<State, Data> tick(final Control tick, final Data data) {
final var pair = Source.single(data)
.viaMat(KillSwitches.single(), Keep.right())
.via(flow)
.toMat(Sink.seq(), Keep.both())
.<Object>map(result -> result)
.orElse(Source.single(Done.done()))
.toMat(Sink.head(), Keep.both())
.run(materializer);

killSwitch = pair.first();
final var resultFuture = pair.second().handle((result, error) -> {
if (error != null || result == null || result.size() > 1) {
if (error != null || result == null) {
final var errorToReport = error != null
? error
: new IllegalStateException("Got unexpected persistence results: " + result);
: new IllegalStateException("Got no persistence result");
return Result.fromError(data.metadata(), errorToReport);
} else if (result.isEmpty()) {
// no result; no change sent to persistence and all acknowledgement requests were fulfilled.
return Done.done();
} else {
return result.get(0);
return result;
}
});

Expand Down

0 comments on commit 4fc79a7

Please sign in to comment.