Example usage for io.netty.buffer ByteBufHolder replace

List of usage examples for io.netty.buffer ByteBufHolder replace

Introduction

In this page you can find the example usage for io.netty.buffer ByteBufHolder replace.

Prototype

ByteBufHolder replace(ByteBuf content);

Source Link

Document

Returns a new ByteBufHolder which contains the specified content .

Usage

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);
    }
}