Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: optmize NettyChannelHandlerAdapter with explict extends. (#1667) #1698

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
Loading