Program: 37507
Project: 37507
Buggy source:
/** 
 * 异步读取,该方法在 reactor 中被调用
 */
@SuppressWarnings("String_Node_Str") @Override public void asynRead() throws IOException {
  if (isClosed.get()) {
    return;
  }
  if (!reading.compareAndSet(false,true)) {
    LOGGER.info("String_Node_Str");
    return;
  }
  try {
    if (readBuffer == null) {
      if (direction == Direction.in)       readBuffer=allocate(1024 * 16);
 else       readBuffer=allocate(1024 * 64);
    }
    lastReadTime=TimeUtil.currentTimeMillis();
    int offset=0;
    for (; ; ) {
      if (isClosed()) {
        return;
      }
      int length=socketChannel.read(readBuffer);
      if (length == -1) {
        this.close("String_Node_Str");
        return;
      }
 else       if (length == 0 && !this.socketChannel.isOpen()) {
        this.close("String_Node_Str");
        return;
      }
      netInBytes+=length;
      netInCounter++;
      if (isFlowLimit() && netFlowMonitor.pool(length)) {
        flowClean();
        return;
      }
      if (!readBuffer.hasRemaining()) {
        if (readBuffer.capacity() >= maxCapacity) {
          LOGGER.warn("String_Node_Str",this);
          throw new IllegalArgumentException("String_Node_Str");
        }
        int newCapacity=readBuffer.capacity() << 1;
        newCapacity=(newCapacity > maxCapacity) ? maxCapacity : newCapacity;
        ByteBuffer newBuffer=allocate(newCapacity);
        readBuffer.position(offset);
        newBuffer.put(readBuffer);
        recycle(readBuffer);
        readBuffer=newBuffer;
        lastLargeMessageTime=TimeUtil.currentTimeMillis();
        largeCounter++;
        continue;
      }
      int dataLength=readBuffer.position();
      readBuffer.position(offset);
      byte[] data=new byte[dataLength];
      readBuffer.get(data,0,dataLength);
      handler.handleReadEvent(this,data);
      if (readBuffer != null && lastLargeMessageTime != 0 && lastLargeMessageTime < (lastReadTime - 30 * 1000L)) {
        if (LOGGER.isDebugEnabled()) {
          LOGGER.debug("String_Node_Str" + readBuffer.capacity());
        }
        ByteBuffer oldBuffer=readBuffer;
        ByteBuffer newBuffer=allocate(1024 * 16);
        readBuffer=newBuffer;
        if (oldBuffer.isDirect())         recycle(oldBuffer);
        lastLargeMessageTime=0;
      }
 else {
        if (readBuffer != null) {
          readBuffer.clear();
        }
      }
      break;
    }
  }
  finally {
    reading.set(false);
  }
}

Fixed version (ground truth):
/** 
 * 异步读取,该方法在 reactor 中被调用
 */
@SuppressWarnings("String_Node_Str") @Override public void asynRead() throws IOException {
  if (isClosed.get()) {
    return;
  }
  if (!reading.compareAndSet(false,true)) {
    LOGGER.info("String_Node_Str");
    return;
  }
  try {
    if (readBuffer == null) {
      if (direction == Direction.in)       readBuffer=allocate(1024 * 16);
 else       readBuffer=allocate(1024 * 64);
    }
    lastReadTime=TimeUtil.currentTimeMillis();
    int offset=0;
    for (; ; ) {
      if (isClosed()) {
        return;
      }
      int length=socketChannel.read(readBuffer);
      if (length == -1) {
        this.close("String_Node_Str");
        return;
      }
 else       if (length == 0 && !this.socketChannel.isOpen()) {
        this.close("String_Node_Str");
        return;
      }
      netInBytes+=length;
      netInCounter++;
      if (isFlowLimit() && netFlowMonitor.pool(length)) {
        flowClean();
        return;
      }
      if (!readBuffer.hasRemaining()) {
        if (readBuffer.capacity() >= maxCapacity) {
          LOGGER.warn("String_Node_Str",this);
          throw new IllegalArgumentException("String_Node_Str");
        }
        int newCapacity=readBuffer.capacity() << 1;
        newCapacity=(newCapacity > maxCapacity) ? maxCapacity : newCapacity;
        ByteBuffer newBuffer=allocate(newCapacity);
        readBuffer.position(offset);
        newBuffer.put(readBuffer);
        recycle(readBuffer);
        readBuffer=newBuffer;
        lastLargeMessageTime=TimeUtil.currentTimeMillis();
        largeCounter++;
        continue;
      }
      int dataLength=readBuffer.position();
      readBuffer.position(offset);
      byte[] data=new byte[dataLength];
      readBuffer.get(data,0,dataLength);
      if (isNested)       handler.handleReadEvent(parent,data);
 else       handler.handleReadEvent(this,data);
      if (readBuffer != null && lastLargeMessageTime != 0 && lastLargeMessageTime < (lastReadTime - 30 * 1000L)) {
        if (LOGGER.isDebugEnabled()) {
          LOGGER.debug("String_Node_Str" + readBuffer.capacity());
        }
        ByteBuffer oldBuffer=readBuffer;
        ByteBuffer newBuffer=allocate(1024 * 16);
        readBuffer=newBuffer;
        if (oldBuffer.isDirect())         recycle(oldBuffer);
        lastLargeMessageTime=0;
      }
 else {
        if (readBuffer != null) {
          readBuffer.clear();
        }
      }
      break;
    }
  }
  finally {
    reading.set(false);
  }
}