Skip to content

Commit

Permalink
fix: Buffer.addPending sets writeRequired
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 Mar 23, 2023
1 parent 4b5f24a commit 8668255
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 8668255

Please sign in to comment.