From ef9531519ae763a72630caaa2a8f5eb25735a9af Mon Sep 17 00:00:00 2001 From: Levi Ramsey Date: Wed, 25 Oct 2023 03:11:38 -0400 Subject: [PATCH] fix: Buffer.addPending sets writeRequired (#1015) ```scala require(pending.isEmpty, "Pending should be empty if write not required") ``` suggests that an invariant of `journal.Buffer` is that `writeRequired || pending.nonEmpty`. The `addPending` method, if called on a `Buffer` where `writeRequired` is `false` will break this invariant, which may cause subsequent adds to the buffer to throw, crashing the `TagWriter` and forcing an `ActorSystem` restart. --- .../main/scala/akka/persistence/cassandra/journal/Buffer.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/scala/akka/persistence/cassandra/journal/Buffer.scala b/core/src/main/scala/akka/persistence/cassandra/journal/Buffer.scala index f3561f1e..07042f7a 100644 --- a/core/src/main/scala/akka/persistence/cassandra/journal/Buffer.scala +++ b/core/src/main/scala/akka/persistence/cassandra/journal/Buffer.scala @@ -107,7 +107,7 @@ private[akka] case class Buffer( } final def addPending(write: AwaitingWrite): Buffer = { - copy(size = size + write.events.size, pending = pending :+ write) + copy(size = size + write.events.size, pending = pending :+ write, writeRequired = true) } def writeComplete(): Buffer = {