Skip to content

Commit

Permalink
fix: Buffer.addPending sets writeRequired (#1015)
Browse files Browse the repository at this point in the history
```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.
  • Loading branch information
leviramsey authored Oct 25, 2023
1 parent ad8f7ba commit ef95315
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit ef95315

Please sign in to comment.