You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pekko.apache.org by he...@apache.org on 2026/07/02 18:57:33 UTC

(pekko-http) 01/01: refactor: fold InHandler and OutHandler into GraphStageLogic in DecoderSpec

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

He-Pin pushed a commit to branch optimize/decoder-spec-handler-folding
in repository https://gitbox.apache.org/repos/asf/pekko-http.git

commit 64487cf6c6a54be779b2f0a66f4f5b591303af87
Author: 虎鸣 <he...@alibaba-inc.com>
AuthorDate: Fri Jul 3 02:50:45 2026 +0800

    refactor: fold InHandler and OutHandler into GraphStageLogic in DecoderSpec
    
    Port akka-http commit from PR #4158: reduce object allocations in test
    DummyDecoder by folding separate InHandler/OutHandler into the
    GraphStageLogic itself using setHandlers(in, out, this).
    
    Tests:
    Not run - pure refactoring of test helper, no behavior change
    
    References:
    Refs akka/akka-http#4158
---
 .../apache/pekko/http/scaladsl/coding/DecoderSpec.scala  | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/coding/DecoderSpec.scala b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/coding/DecoderSpec.scala
index 2b6609b0d..302503f8f 100644
--- a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/coding/DecoderSpec.scala
+++ b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/coding/DecoderSpec.scala
@@ -56,16 +56,12 @@ class DecoderSpec extends AnyWordSpec with CodecSpecSupport {
     override def newDecompressorStage(maxBytesPerChunk: Int): () => GraphStage[FlowShape[ByteString, ByteString]] =
       () =>
         new SimpleLinearGraphStage[ByteString] {
-          override def createLogic(inheritedAttributes: Attributes): GraphStageLogic = new GraphStageLogic(shape) {
-            setHandler(in,
-              new InHandler {
-                override def onPush(): Unit = push(out, grab(in) ++ ByteString("compressed"))
-              })
-            setHandler(out,
-              new OutHandler {
-                override def onPull(): Unit = pull(in)
-              })
-          }
+          override def createLogic(inheritedAttributes: Attributes): GraphStageLogic =
+            new GraphStageLogic(shape) with InHandler with OutHandler {
+              override def onPush(): Unit = push(out, grab(in) ++ ByteString("compressed"))
+              override def onPull(): Unit = pull(in)
+              setHandlers(in, out, this)
+            }
         }
   }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pekko.apache.org
For additional commands, e-mail: commits-help@pekko.apache.org