[#1800] [#1802] Correctly expand capacity of ByteBuf while preserve content