He-Pin commented on code in PR #1142:
URL: https://github.com/apache/pekko-http/pull/1142#discussion_r3543793702


##########
http-core/src/main/scala/org/apache/pekko/http/impl/util/StreamUtils.scala:
##########
@@ -58,11 +64,17 @@ private[http] object StreamUtils {
           override def onPull(): Unit = pull(in)
 
           override def onUpstreamFinish(): Unit = {
-            val data = finish()
-            if (data.nonEmpty) emit(out, data)
-            completeStage()
+            try {
+              val data = finish()
+              if (data.nonEmpty) emit(out, data)
+              completeStage()
+            } finally {
+              finished = true

Review Comment:
   Setting  in the finally block prevents  from calling  if  throws. In that 
failure path the stage still stops, but  is false, so the deflater leak this PR 
is trying to fix can still happen. Please move the flag assignment onto the 
success path, right before . That keeps the happy path idempotent while still 
letting  clean up on exceptions.



##########
http-core/src/main/scala/org/apache/pekko/http/impl/util/StreamUtils.scala:
##########
@@ -58,11 +64,17 @@ private[http] object StreamUtils {
           override def onPull(): Unit = pull(in)
 
           override def onUpstreamFinish(): Unit = {
-            val data = finish()
-            if (data.nonEmpty) emit(out, data)
-            completeStage()
+            try {
+              val data = finish()
+              if (data.nonEmpty) emit(out, data)
+              completeStage()
+            } finally {
+              finished = true

Review Comment:
   Setting the finished flag in the finally block prevents postStop() from 
calling cleanup() if finish() throws. In that failure path the stage still 
stops, but the finished guard is already true, so the deflater leak this PR is 
trying to fix can still happen. Please move the flag assignment onto the 
success path, right before completeStage(). That keeps the happy path 
idempotent while still letting postStop() clean up on exceptions.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to