This is an automated email from the ASF dual-hosted git repository.

liguobin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-pekko.git


The following commit(s) were added to refs/heads/main by this push:
     new 417196fb46 Optimize closeState flag (#872)
417196fb46 is described below

commit 417196fb46e68b228af5b06b63f29ff0358b30a8
Author: jxnu-liguobin <[email protected]>
AuthorDate: Mon Dec 25 08:30:27 2023 +0800

    Optimize closeState flag (#872)
    
    Co-authored-by: jxnu-liguobin <[email protected]>
---
 stream/src/main/scala/org/apache/pekko/stream/impl/fusing/Ops.scala | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git 
a/stream/src/main/scala/org/apache/pekko/stream/impl/fusing/Ops.scala 
b/stream/src/main/scala/org/apache/pekko/stream/impl/fusing/Ops.scala
index d70b1c9bbb..5368955e7b 100644
--- a/stream/src/main/scala/org/apache/pekko/stream/impl/fusing/Ops.scala
+++ b/stream/src/main/scala/org/apache/pekko/stream/impl/fusing/Ops.scala
@@ -2251,8 +2251,8 @@ private[pekko] final class StatefulMap[S, In, 
Out](create: () => S, f: (S, In) =
       override def onUpstreamFailure(ex: Throwable): Unit = 
closeStateAndFail(ex)
 
       override def onDownstreamFinish(cause: Throwable): Unit = {
-        onComplete(state)
         needInvokeOnCompleteCallback = false
+        onComplete(state)
         super.onDownstreamFinish(cause)
       }
 
@@ -2265,19 +2265,19 @@ private[pekko] final class StatefulMap[S, In, 
Out](create: () => S, f: (S, In) =
       }
 
       private def closeStateAndComplete(): Unit = {
+        needInvokeOnCompleteCallback = false
         onComplete(state) match {
           case Some(elem) => emit(out, elem, () => completeStage())
           case None       => completeStage()
         }
-        needInvokeOnCompleteCallback = false
       }
 
       private def closeStateAndFail(ex: Throwable): Unit = {
+        needInvokeOnCompleteCallback = false
         onComplete(state) match {
           case Some(elem) => emit(out, elem, () => failStage(ex))
           case None       => failStage(ex)
         }
-        needInvokeOnCompleteCallback = false
       }
 
       override def onPull(): Unit = pull(in)


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

Reply via email to