fix: Fix a leak in PrefixAndTail operator. (#1623)

This commit is contained in:
He-Pin(kerr) 2025-01-03 21:46:40 +08:00 committed by GitHub
parent 2b6d2dc0a0
commit d34927b56b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -237,7 +237,9 @@ import pekko.util.ccompat.JavaConverters._
override def onUpstreamFinish(): Unit = {
if (!prefixComplete) {
// This handles the unpulled out case as well
emit(out, (builder.result(), Source.empty), () => completeStage())
val prefix = builder.result();
builder = null // free for GC
emit(out, (prefix, Source.empty), () => completeStage())
} else {
if (!tailSource.isClosed) tailSource.complete()
completeStage()