Skip to content

Commit

Permalink
Use SimpleChannelInboundHandler to filter on ByteBuf
Browse files Browse the repository at this point in the history
  • Loading branch information
RagnarW authored and martinfurmanski committed Sep 10, 2018
1 parent 2832668 commit 4414fa8
Showing 1 changed file with 5 additions and 5 deletions.
Expand Up @@ -24,13 +24,13 @@

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.util.ReferenceCountUtil;

import org.neo4j.causalclustering.catchup.Protocol;
import org.neo4j.causalclustering.messaging.marshalling.v2.ContentType;

public class ContentTypeDispatcher extends ChannelInboundHandlerAdapter
public class ContentTypeDispatcher extends SimpleChannelInboundHandler<ByteBuf>
{
private final Protocol<ContentType> contentTypeProtocol;

Expand All @@ -40,14 +40,14 @@ public ContentTypeDispatcher( Protocol<ContentType> contentTypeProtocol )
}

@Override
public void channelRead( ChannelHandlerContext ctx, Object msg )
protected void channelRead0( ChannelHandlerContext ctx, ByteBuf msg )
{
if ( contentTypeProtocol.isExpecting( ContentType.ContentType ) )
{
byte messageCode = ((ByteBuf) msg).readByte();
byte messageCode = msg.readByte();
ContentType contentType = getContentType( messageCode );
contentTypeProtocol.expect( contentType );
if ( ((ByteBuf) msg).readableBytes() == 0 )
if ( msg.readableBytes() == 0 )
{
ReferenceCountUtil.release( msg );
return;
Expand Down

0 comments on commit 4414fa8

Please sign in to comment.