class ImapRequestFrameDecoder extends FrameDecoder implements NettyConstants {

    @Override
    protected synchronized ChannelBuffer newCumulationBuffer(ChannelHandlerContext ctx, int minimumCapacity) {
        Map<String, Object> attachment = (Map<String, Object>) ctx.getAttachment();
        Object sizeAsObject = attachment.get(NEEDED_DATA);
        if (sizeAsObject != null) {
            @SuppressWarnings("unchecked")
            int size = (Integer) sizeAsObject;

            if (size > 0) {
                int sanitizedInMemorySizeLimit = Math.max(0, inMemorySizeLimit);
                int sanitizedSize = Math.min(sanitizedInMemorySizeLimit, size);

                return ChannelBuffers.dynamicBuffer(sanitizedSize, ctx.getChannel().getConfig().getBufferFactory());
            }
        }
        return super.newCumulationBuffer(ctx, minimumCapacity);
    }

    public  ImapRequestFrameDecoder(ImapDecoder decoder, int inMemorySizeLimit, int literalSizeLimit);

}