Handle expected case of empty flux in message deletion

This commit is contained in:
Chris Eager
2022-10-31 11:25:39 -05:00
committed by Chris Eager
parent c10fda8363
commit aa829af43b
2 changed files with 15 additions and 4 deletions

View File

@@ -175,9 +175,9 @@ public class MessagesDynamoDb extends AbstractDynamoDbStore {
}
return null;
})
.last()
.toFuture()
.thenApply(Optional::ofNullable);
.map(Optional::ofNullable)
.last(Optional.empty()) // if the flux is empty, last() will throw without a default
.toFuture();
}
public CompletableFuture<Optional<MessageProtos.Envelope>> deleteMessage(final UUID destinationAccountUuid,