From 6a6639ffe215a6a790c81c0c9e69c501e9d3651c Mon Sep 17 00:00:00 2001 From: He-Pin Date: Wed, 13 Sep 2023 00:03:58 +0800 Subject: [PATCH] Remove the duplicated code in NettyHelpers. --- .../remote/transport/netty/NettyHelpers.scala | 31 ++++++------------- 1 file changed, 9 insertions(+), 22 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 8e3a7c55a02..eddec5b82c3 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 @@ -52,15 +52,16 @@ private[netty] trait NettyHelpers { /** * INTERNAL API */ -private[netty] trait NettyServerHelpers extends SimpleChannelInboundHandler[ByteBuf] with NettyHelpers { - +private[netty] abstract class NettyChannelHandlerAdapter extends SimpleChannelInboundHandler[ByteBuf] + with NettyHelpers { final override def channelRead0(ctx: ChannelHandlerContext, msg: ByteBuf): Unit = { onMessage(ctx, msg) } @nowarn("msg=deprecated") - final override def exceptionCaught(ctx: ChannelHandlerContext, cause: Throwable): Unit = + final override def exceptionCaught(ctx: ChannelHandlerContext, cause: Throwable): Unit = { transformException(ctx, cause) + } final override def channelActive(ctx: ChannelHandlerContext): Unit = { onOpen(ctx) @@ -75,23 +76,9 @@ private[netty] trait NettyServerHelpers extends SimpleChannelInboundHandler[Byte /** * INTERNAL API */ -private[netty] trait NettyClientHelpers extends SimpleChannelInboundHandler[ByteBuf] with NettyHelpers { - - final override def channelRead0(ctx: ChannelHandlerContext, msg: ByteBuf): Unit = { - onMessage(ctx, msg) - } - - @nowarn("msg=deprecated") - final override def exceptionCaught(ctx: ChannelHandlerContext, cause: Throwable): Unit = { - transformException(ctx, cause) - } +private[netty] trait NettyServerHelpers extends NettyChannelHandlerAdapter - final override def channelActive(ctx: ChannelHandlerContext): Unit = { - onOpen(ctx) - onConnect(ctx) - } - - final override def channelInactive(ctx: ChannelHandlerContext): Unit = { - onDisconnect(ctx) - } -} +/** + * INTERNAL API + */ +private[netty] trait NettyClientHelpers extends NettyChannelHandlerAdapter