From 42cca6bfdf43f2fa199bb43fd594b35ecf74c5a1 Mon Sep 17 00:00:00 2001 From: He-Pin Date: Sun, 22 Dec 2024 19:17:38 +0800 Subject: [PATCH] fix: Fix a leak in PrefixAndTail operator. --- .../org/apache/pekko/stream/impl/fusing/StreamOfStreams.scala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stream/src/main/scala/org/apache/pekko/stream/impl/fusing/StreamOfStreams.scala b/stream/src/main/scala/org/apache/pekko/stream/impl/fusing/StreamOfStreams.scala index dc84291b2ef..4c9b9cea7b2 100644 --- a/stream/src/main/scala/org/apache/pekko/stream/impl/fusing/StreamOfStreams.scala +++ b/stream/src/main/scala/org/apache/pekko/stream/impl/fusing/StreamOfStreams.scala @@ -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()