Package io.netty.buffer

Examples of io.netty.buffer.ByteBuf.retain()


            files.put(data.getName(), values);
          }
          try {
            FileUpload nettyFileUpload = (FileUpload) data;
            final ByteBuf byteBuf = nettyFileUpload.getByteBuf();
            byteBuf.retain();
            context.onClose(new Action<RequestOutcome>() {
              @Override
              public void execute(RequestOutcome thing) throws Exception {
                byteBuf.release();
              }
View Full Code Here


    // read the protobuf body into a buffer.
    checkTag(is, RpcEncoder.PROTOBUF_BODY_TAG);
    final int pBodyLength = readRawVarint32(is);
    final ByteBuf pBody = buffer.slice(buffer.readerIndex(), pBodyLength);
    buffer.skipBytes(pBodyLength);
    pBody.retain();
    if (RpcConstants.EXTRA_DEBUGGING) {
      logger.debug("Read protobuf body of length {} into buffer {}.", pBodyLength, pBody);
    }

    if (RpcConstants.EXTRA_DEBUGGING) {
View Full Code Here

      dBodyLength = readRawVarint32(is);
      if (buffer.readableBytes() != dBodyLength) {
        throw new CorruptedFrameException(String.format("Expected to receive a raw body of %d bytes but received a buffer with %d bytes.", dBodyLength, buffer.readableBytes()));
      }
      dBody = buffer.slice();
      dBody.retain();
      if (RpcConstants.EXTRA_DEBUGGING) {
        logger.debug("Read raw body of {}", dBody);
      }

    }else{
View Full Code Here

    };

    ByteBuf buf = encode(ch, envelopes);

    // 1. complete ByteBuf as input
    int refCount = buf.retain().refCnt();

    decodeAndVerify(ch, buf, envelopes);
    Assert.assertEquals(refCount - 1, buf.refCnt());

    // 2. random slices
View Full Code Here

  public NetSocket write(Buffer data) {
    ByteBuf buf = data.getByteBuf();
    if (data.isWrapper()) {
      // call retain to make sure it is not released before the write completes
      // the write will call buf.release() by it own
      buf.retain();
    }
    doWrite(buf);
    return this;
  }
View Full Code Here

  protected void writeBinaryFrameInternal(Buffer data) {
    ByteBuf buf = data.getByteBuf();
    if (data.isWrapper()) {
      // call retain to make sure it is not released before the write completes
      // the write will call buf.release() by it own
      buf.retain();
    }
    WebSocketFrame frame = new DefaultWebSocketFrame(WebSocketFrame.FrameType.BINARY, buf);
    writeFrame(frame);
  }
View Full Code Here

  public DefaultHttpServerResponse write(Buffer chunk) {
    ByteBuf buf = chunk.getByteBuf();
    if (chunk.isWrapper()) {
      // call retain to make sure it is not released before the write completes
      // the write will call buf.release() by it own
      buf.retain();
    }
    return write(buf, null);
  }

  @Override
View Full Code Here

    check();
    ByteBuf buf = chunk.getByteBuf();
    if (chunk.isWrapper()) {
      // call retain to make sure it is not released before the write completes
      // the write will call buf.release() by it own
      buf.retain();
    }
    return write(buf);
  }

  @Override
View Full Code Here

    public void execute(Execution execution) throws Exception {
      HttpClients.httpClient(execController, UnpooledByteBufAllocator.DEFAULT, Integer.MAX_VALUE).request(uri, action)
        .then(response -> {
          TypedData responseBody = response.getBody();
          ByteBuf responseBodyBuffer = responseBody.getBuffer();
          responseBodyBuffer = Unpooled.unreleasableBuffer(responseBodyBuffer.retain());
          ReceivedResponse copiedResponse = new DefaultReceivedResponse(
            response.getStatus(),
            response.getHeaders(),
            new ByteBufBackedTypedData(responseBodyBuffer, responseBody.getContentType())
          );
View Full Code Here

    };

    ByteBuf buf = encode(ch, envelopes);

    // 1. complete ByteBuf as input
    int refCount = buf.retain().refCnt();

    decodeAndVerify(ch, buf, envelopes);
    Assert.assertEquals(refCount - 1, buf.refCnt());

    // 2. random slices
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.