Skip to content

Commit

Permalink
We need to retain the wrapped buffer, not the components
Browse files Browse the repository at this point in the history
  • Loading branch information
kitskub committed Jan 26, 2014
1 parent 5795ea8 commit fa1b31e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ protected final void initChannel(SocketChannel c) {
MessageEncoder encoder = new MessageEncoder(handler);

// Left to right for encoding/sending/outbound; Right to left for decoding/receiving/inbound
c.pipeline().addLast(processorDecoder, processorEncoder, decoder, encoder, handler);
c.pipeline()
.addLast("processorDecoder", processorDecoder)
.addLast("decoder", decoder)
.addLast("processorEncoder", processorEncoder)
.addLast("encoder", encoder)
.addLast("handler", handler);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,11 @@ protected void encode(ChannelHandlerContext ctx, Message message, List<Object> o
throw new IOException("Unknown message type: " + clazz + ".");
}
final ByteBuf messageBuf = ctx.alloc().buffer();
messageBuf.retain();
reg.getCodec().encode(messageBuf, message);


final ByteBuf headerBuf = ctx.alloc().buffer();
headerBuf.retain();
protocol.writeHeader(headerBuf, reg, messageBuf);
out.add(Unpooled.wrappedBuffer(headerBuf, messageBuf));
out.add(Unpooled.wrappedBuffer(headerBuf, messageBuf).retain());
}
}

0 comments on commit fa1b31e

Please sign in to comment.