This is an automated email from the ASF dual-hosted git repository.
hepin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko.git
The following commit(s) were added to refs/heads/main by this push:
new 03712a927e perf: optmize NettyChannelHandlerAdapter with explict
extends. (#1667)
03712a927e is described below
commit 03712a927e67723e9ffeadaa0b774dae45cbea88
Author: He-Pin(kerr) <[email protected]>
AuthorDate: Sat Jan 4 00:27:42 2025 +0800
perf: optmize NettyChannelHandlerAdapter with explict extends. (#1667)
---
.../pekko/remote/transport/netty/NettyHelpers.scala | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git
a/remote/src/main/scala/org/apache/pekko/remote/transport/netty/NettyHelpers.scala
b/remote/src/main/scala/org/apache/pekko/remote/transport/netty/NettyHelpers.scala
index 3b17a57730..f1bcbe6697 100644
---
a/remote/src/main/scala/org/apache/pekko/remote/transport/netty/NettyHelpers.scala
+++
b/remote/src/main/scala/org/apache/pekko/remote/transport/netty/NettyHelpers.scala
@@ -23,7 +23,7 @@ import pekko.PekkoException
import pekko.util.unused
import io.netty.buffer.ByteBuf
-import io.netty.channel.{ ChannelHandlerContext, SimpleChannelInboundHandler }
+import io.netty.channel.{ ChannelHandlerContext, ChannelInboundHandlerAdapter }
/**
* INTERNAL API
@@ -53,10 +53,19 @@ private[netty] trait NettyHelpers {
/**
* INTERNAL API
*/
-private[netty] abstract class NettyChannelHandlerAdapter extends
SimpleChannelInboundHandler[ByteBuf]
+private[netty] abstract class NettyChannelHandlerAdapter extends
ChannelInboundHandlerAdapter
with NettyHelpers {
- final override def channelRead0(ctx: ChannelHandlerContext, msg: ByteBuf):
Unit = {
- onMessage(ctx, msg)
+
+ final override def channelRead(ctx: ChannelHandlerContext, msg: AnyRef):
Unit = {
+ msg match {
+ case buf: ByteBuf =>
+ try {
+ onMessage(ctx, buf)
+ } catch {
+ case ex: Throwable => transformException(ctx, ex)
+ } finally buf.release() // ByteBuf must be released explicitly
+ case _ => ctx.fireChannelRead(msg)
+ }
}
@nowarn("msg=deprecated")
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]