Skip to content

Commit

Permalink
Allow to @OverRide the cumulative ChannelBuffer creation. See netty#169
Browse files Browse the repository at this point in the history
  • Loading branch information
normanmaurer committed Jan 31, 2012
1 parent 5a91bd3 commit 02f49af
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions codec/src/main/java/io/netty/handler/codec/frame/FrameDecoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,20 @@ private void cleanup(ChannelHandlerContext ctx, ChannelStateEvent e)
private ChannelBuffer cumulation(ChannelHandlerContext ctx) {
ChannelBuffer c = cumulation;
if (c == null) {
c = ChannelBuffers.dynamicBuffer(
ctx.getChannel().getConfig().getBufferFactory());
c = createCumulationDynamicBuffer(ctx);
cumulation = c;
}
return c;
}

/**
* Create a new {@link ChannelBuffer} which is used for the cumulation. Be aware that this MUST be a dynamic buffer. Sub-classes may override this to provide a
* dynamic {@link ChannelBuffer} which has some prelocated size that better fit their need.
*
* @param ctx {@link ChannelHandlerContext} for this handler
* @return buffer the {@link ChannelBuffer} which is used for cumulation
*/
protected ChannelBuffer createCumulationDynamicBuffer(ChannelHandlerContext ctx) {
return ChannelBuffers.dynamicBuffer(ctx.getChannel().getConfig().getBufferFactory());
}
}

0 comments on commit 02f49af

Please sign in to comment.