List of usage examples for io.netty.buffer ByteBufHolder replace
ByteBufHolder replace(ByteBuf content);
From source file:com.linecorp.armeria.internal.PooledObjects.java
License:Apache License
private static <T> T copyAndRelease(ByteBufHolder o) { try {/*from w ww.j a v a 2 s . c o m*/ final ByteBuf content = Unpooled.wrappedBuffer(ByteBufUtil.getBytes(o.content())); @SuppressWarnings("unchecked") final T copy = (T) o.replace(content); return copy; } finally { ReferenceCountUtil.safeRelease(o); } }