Program: 37484
Project: 37484
Buggy source:
@Override public void write(ByteBuffer buf){
  try {
    for (; ; ) {
      if (!rwLock.compareAndSet(false,true)) {
        break;
      }
    }
    buf.flip();
    int bufSize=buf.limit();
    if (bufSize <= MAPPED_SIZE) {
      mappedByteBuffer.clear();
      int position=0;
      int count=fileChannel.write(buf,position);
      if (buf.hasRemaining()) {
        throw new IOException("String_Node_Str" + count + "String_Node_Str"+ buf.remaining());
      }
 else {
        NetSystem.getInstance().getBufferPool().recycle(buf);
      }
      int tranfered=write0(position,count);
      netOutCounter++;
      netOutBytes+=tranfered;
      lastWriteTime=TimeUtil.currentTimeMillis();
    }
 else {
      int cnt=(bufSize / MAPPED_SIZE) + (bufSize % MAPPED_SIZE > 0 ? 1 : 0);
      int postion=0;
      for (int i=1; i <= cnt; i++) {
        int limit=MAPPED_SIZE * i;
        if (limit > bufSize) {
          limit=bufSize;
        }
        buf.position(postion);
        buf.limit(limit);
        ByteBuffer tmpBuf=buf.slice();
        mappedByteBuffer.clear();
        int count=fileChannel.write(tmpBuf,0);
        if (tmpBuf.hasRemaining()) {
          throw new IOException("String_Node_Str" + count + "String_Node_Str"+ tmpBuf.remaining());
        }
        int tranfered=write0(0,count);
        postion+=tranfered;
        netOutCounter++;
        netOutBytes+=tranfered;
        lastWriteTime=TimeUtil.currentTimeMillis();
      }
      NetSystem.getInstance().getBufferPool().recycle(buf);
    }
  }
 catch (  IOException e) {
    LOGGER.error("String_Node_Str",e);
    this.close("String_Node_Str" + e);
  }
 finally {
    rwLock.set(false);
  }
}

Fixed version (ground truth):
@Override public void write(ByteBuffer buf){
  try {
    for (; ; ) {
      if (!rwLock.compareAndSet(false,true)) {
        break;
      }
    }
    buf.flip();
    int bufSize=buf.limit();
    if (bufSize <= MAPPED_SIZE) {
      mappedByteBuffer.clear();
      int position=0;
      int count=fileChannel.write(buf,position);
      if (buf.hasRemaining()) {
        throw new IOException("String_Node_Str" + count + "String_Node_Str"+ buf.remaining());
      }
      int tranfered=write0(position,count);
      netOutCounter++;
      netOutBytes+=tranfered;
      lastWriteTime=TimeUtil.currentTimeMillis();
      NetSystem.getInstance().getBufferPool().recycle(buf);
    }
 else {
      int cnt=(bufSize / MAPPED_SIZE) + (bufSize % MAPPED_SIZE > 0 ? 1 : 0);
      int postion=0;
      for (int i=1; i <= cnt; i++) {
        int limit=MAPPED_SIZE * i;
        if (limit > bufSize) {
          limit=bufSize;
        }
        buf.position(postion);
        buf.limit(limit);
        ByteBuffer tmpBuf=buf.slice();
        mappedByteBuffer.clear();
        int count=fileChannel.write(tmpBuf,0);
        if (tmpBuf.hasRemaining()) {
          throw new IOException("String_Node_Str" + count + "String_Node_Str"+ tmpBuf.remaining());
        }
        int tranfered=write0(0,count);
        postion+=tranfered;
        netOutCounter++;
        netOutBytes+=tranfered;
        lastWriteTime=TimeUtil.currentTimeMillis();
      }
      NetSystem.getInstance().getBufferPool().recycle(buf);
    }
  }
 catch (  IOException e) {
    LOGGER.error("String_Node_Str",e);
    this.close("String_Node_Str" + e);
  }
 finally {
    rwLock.set(false);
  }
}