Java Code Examples for io.netty.buffer.ByteBuf.refCnt()

The following are Jave code examples for showing how to use refCnt() of the io.netty.buffer.ByteBuf class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: angel   File: MatrixTransportClient.java   Source Code and License Vote up 5 votes
private void returnBuffer(Request item) {
  ByteBuf buf = item.getContext().getSerializedData();
  if(buf != null && buf.refCnt() > 0) {
    try {
      buf.release();
    } catch (Throwable x) {
      LOG.error("Release Buffer failed." , x);
    }
    item.getContext().setSerializedData(null);
  }
}
 
Example 2
Project: j1st-mqtt   File: MqttPublishMessage.java   Source Code and License Vote up 5 votes
@Override
public ByteBuf content() {
    final ByteBuf data = (ByteBuf) super.payload();
    if (data.refCnt() <= 0) {
        throw new IllegalReferenceCountException(data.refCnt());
    }
    return data;
}
 
Example 3
Project: DovakinMQ   File: MqttPublishMessage.java   Source Code and License Vote up 5 votes
@Override
public ByteBuf content() {
    final ByteBuf data = (ByteBuf) super.payload();
    if (data.refCnt() <= 0) {
        throw new IllegalReferenceCountException(data.refCnt());
    }
    return data;
}
 
Example 4
Project: jsf-sdk   File: MsgFuture.java   Source Code and License Vote up 5 votes
private synchronized void releaseIfNeed0(V result){
    if(result instanceof ResponseMessage){
        ByteBuf byteBuf = ((ResponseMessage) result).getMsgBody();
        if(byteBuf != null && byteBuf.refCnt() > 0 ){
            byteBuf.release();
        }
    }
}