Merge pull request #28542 from fredfp/issue-28541

Shield unsafe journal plugins from corner case, #28541
This commit is contained in:
Renato Cavalcanti 2020-02-13 13:46:21 +01:00 committed by GitHub
commit ec3d67df7e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -69,6 +69,11 @@ trait AsyncWriteJournal extends Actor with WriteJournalBase with AsyncRecovery {
val atomicWriteCount = messages.count(_.isInstanceOf[AtomicWrite])
val prepared = Try(preparePersistentBatch(messages))
val writeResult = (prepared match {
case Success(prep) if prep.isEmpty =>
// prep is empty when all messages are instances of NonPersistentRepr (used for defer) in that case,
// we continue right away without calling the journal plugin (most plugins fail calling head on empty Seq).
// Ordering of the replies is handled by Resequencer
Future.successful(Nil)
case Success(prep) =>
// try in case the asyncWriteMessages throws
try breaker.withCircuitBreaker(asyncWriteMessages(prep))