nus-yam/ex-repair huggingface dataset:
Program: 37485
Project: 37485
Buggy source:
public ZeroCopyConnection(SocketChannel channel){
  super(channel);
  try {
    String path=System.getProperty("String_Node_Str");
    if (path == null) {
      if (JavaUtils.isLinux())       path="String_Node_Str";
 else       path="String_Node_Str";
    }
    this.fileName=path + id + "String_Node_Str";
    this.file=new File(this.fileName);
    ensureDirOK(this.file.getParent());
    this.randomAccessFile=new RandomAccessFile(file,"String_Node_Str");
    this.randomAccessFile.setLength(MAPPED_SIZE);
    this.randomAccessFile.seek(0);
    this.fileChannel=randomAccessFile.getChannel();
    this.mappedByteBuffer=fileChannel.map(FileChannel.MapMode.READ_WRITE,0,MAPPED_SIZE);
  }
 catch (  IOException e) {
    LOGGER.error("String_Node_Str",e);
  }
}

Fixed version (ground truth):
public ZeroCopyConnection(SocketChannel channel){
  super(channel);
  try {
    this.fileName=MAPPED_PATH + id + MAPPED_SUFFIX;
    this.file=new File(this.fileName);
    this.randomAccessFile=new RandomAccessFile(file,"String_Node_Str");
    this.randomAccessFile.setLength(MAPPED_SIZE);
    this.randomAccessFile.seek(0);
    this.fileChannel=randomAccessFile.getChannel();
    this.mappedByteBuffer=fileChannel.map(FileChannel.MapMode.READ_WRITE,0,MAPPED_SIZE);
  }
 catch (  IOException e) {
    LOGGER.error("String_Node_Str",e);
  }
}
Program: 37486
Project: 37486
Buggy source:
private void ensureDirOK(final String dirName){
  if (dirName != null) {
    File f=new File(dirName);
    if (!f.exists()) {
      boolean result=f.mkdirs();
      LOGGER.info(dirName + "String_Node_Str" + (result ? "String_Node_Str" : "String_Node_Str"));
    }
  }
}

Fixed version (ground truth):
private static void ensureDirOK(String dirName){
  if (dirName != null) {
    File f=new File(dirName);
    if (!f.exists()) {
      boolean result=f.mkdirs();
      LOGGER.info(dirName + "String_Node_Str" + (result ? "String_Node_Str" : "String_Node_Str"));
    }
 else {
      String[] mfList=f.list(new FilenameFilter(){
        @Override public boolean accept(        File dir,        String name){
          return name.endsWith(MAPPED_SUFFIX);
        }
      }
);
      if (mfList != null && mfList.length > 0) {
        for (        String mf : mfList) {
          File mff=new File(mf);
          if (mff != null && mff.exists()) {
            mff.delete();
            LOGGER.info("String_Node_Str",mff.getName());
          }
        }
      }
    }
  }
}
Program: 37488
Project: 37488
Buggy source:
@Override public String toString(){
  StringBuffer sbuffer=new StringBuffer(100);
  sbuffer.append(delegateConn.toString());
  sbuffer.append("String_Node_Str");
  sbuffer.append("String_Node_Str").append(borrowed);
  sbuffer.append("String_Node_Str").append(isZeroCopy);
  if (heartbeatTime > 0) {
    sbuffer.append("String_Node_Str").append(heartbeatTime);
  }
  sbuffer.append("String_Node_Str");
  return sbuffer.toString();
}

Fixed version (ground truth):
@Override public String toString(){
  StringBuffer sbuffer=new StringBuffer(100);
  sbuffer.append(delegateConn.toString());
  sbuffer.append("String_Node_Str").append(borrowed);
  sbuffer.append("String_Node_Str").append(isZeroCopy);
  if (heartbeatTime > 0) {
    sbuffer.append("String_Node_Str").append(heartbeatTime);
  }
  sbuffer.append("String_Node_Str");
  return sbuffer.toString();
}
Program: 37489
Project: 37489
Buggy source:
@Override public String toString(){
  StringBuffer sbuffer=new StringBuffer(200);
  sbuffer.append("String_Node_Str").append(reactor);
  sbuffer.append("String_Node_Str").append(host).append("String_Node_Str").append(port);
  sbuffer.append("String_Node_Str").append(userCfg != null ? userCfg.getPassword() : "String_Node_Str");
  sbuffer.append("String_Node_Str").append(id);
  if (session != null) {
    sbuffer.append("String_Node_Str").append(session.getRequestCmd());
    sbuffer.append("String_Node_Str").append(session.getRequestKey() != null ? new String(session.getRequestKey()) : "String_Node_Str");
  }
  sbuffer.append("String_Node_Str").append(_readLock.get());
  sbuffer.append("String_Node_Str").append(TimeUtil.formatTimestamp(startupTime));
  sbuffer.append("String_Node_Str").append(TimeUtil.formatTimestamp(lastReadTime));
  sbuffer.append("String_Node_Str").append(TimeUtil.formatTimestamp(lastWriteTime));
  sbuffer.append("String_Node_Str").append(writeAttempts);
  if (isClosed.get()) {
    sbuffer.append("String_Node_Str").append(TimeUtil.formatTimestamp(closeTime));
    sbuffer.append("String_Node_Str").append(closeReason);
  }
  sbuffer.append("String_Node_Str").append(isClosed.get());
  sbuffer.append("String_Node_Str");
  return sbuffer.toString();
}

Fixed version (ground truth):
@Override public String toString(){
  StringBuffer sbuffer=new StringBuffer(200);
  sbuffer.append("String_Node_Str").append(reactor);
  sbuffer.append("String_Node_Str").append(host).append("String_Node_Str").append(port);
  sbuffer.append("String_Node_Str").append(userCfg != null ? userCfg.getPassword() : "String_Node_Str");
  sbuffer.append("String_Node_Str").append(id);
  if (session != null) {
    sbuffer.append("String_Node_Str").append(session.getRequestCmd());
    sbuffer.append("String_Node_Str").append(session.getRequestKey() != null ? new String(session.getRequestKey()) : "String_Node_Str");
  }
  sbuffer.append("String_Node_Str").append(_readLock.get());
  sbuffer.append("String_Node_Str").append(TimeUtil.formatTimestamp(startupTime));
  sbuffer.append("String_Node_Str").append(TimeUtil.formatTimestamp(lastReadTime));
  sbuffer.append("String_Node_Str").append(TimeUtil.formatTimestamp(lastWriteTime));
  sbuffer.append("String_Node_Str").append(writeAttempts);
  if (isClosed.get()) {
    sbuffer.append("String_Node_Str").append(isClosed.get());
    sbuffer.append("String_Node_Str").append(TimeUtil.formatTimestamp(closeTime));
    sbuffer.append("String_Node_Str").append(closeReason);
  }
  sbuffer.append("String_Node_Str");
  return sbuffer.toString();
}
Program: 37491
Project: 37491
Buggy source:
@Override public String toString(){
  StringBuffer sbuffer=new StringBuffer(100);
  sbuffer.append("String_Node_Str");
  sbuffer.append("String_Node_Str").append(reactor);
  sbuffer.append("String_Node_Str").append(host);
  sbuffer.append("String_Node_Str").append(port);
  sbuffer.append("String_Node_Str").append(id);
  sbuffer.append("String_Node_Str").append(startupTime);
  sbuffer.append("String_Node_Str").append(lastReadTime);
  sbuffer.append("String_Node_Str").append(lastWriteTime);
  sbuffer.append("String_Node_Str").append(writeAttempts);
  sbuffer.append("String_Node_Str").append(netInCounter).append("String_Node_Str").append(netOutCounter);
  if (isClosed.get()) {
    sbuffer.append("String_Node_Str").append(isClosed);
    sbuffer.append("String_Node_Str").append(closeTime);
    sbuffer.append("String_Node_Str").append(closeReason);
  }
  sbuffer.append("String_Node_Str");
  return sbuffer.toString();
}

Fixed version (ground truth):
@Override public String toString(){
  StringBuffer sbuffer=new StringBuffer(100);
  sbuffer.append("String_Node_Str");
  sbuffer.append("String_Node_Str").append(reactor);
  sbuffer.append("String_Node_Str").append(host).append("String_Node_Str").append(port);
  sbuffer.append("String_Node_Str").append(id);
  sbuffer.append("String_Node_Str").append(startupTime);
  sbuffer.append("String_Node_Str").append(lastReadTime);
  sbuffer.append("String_Node_Str").append(lastWriteTime);
  sbuffer.append("String_Node_Str").append(writeAttempts);
  sbuffer.append("String_Node_Str").append(netInCounter).append("String_Node_Str").append(netOutCounter);
  if (isClosed.get()) {
    sbuffer.append("String_Node_Str").append(isClosed);
    sbuffer.append("String_Node_Str").append(closeTime);
    sbuffer.append("String_Node_Str").append(closeReason);
  }
  sbuffer.append("String_Node_Str");
  return sbuffer.toString();
}
Program: 37492
Project: 37492
Buggy source:
@SuppressWarnings("String_Node_Str") @Override public void asynRead() throws IOException {
  if (isClosed.get()) {
    return;
  }
  if (!rwLock.compareAndSet(false,true)) {
    return;
  }
  lastReadTime=TimeUtil.currentTimeMillis();
  try {
    for (; ; ) {
      int position=mappedByteBuffer.position();
      int count=MAPPED_SIZE - position;
      int tranfered=(int)fileChannel.transferFrom(socketChannel,position,count);
      mappedByteBuffer.position(position + tranfered);
      if (tranfered == 0 && count > 0) {
        tranfered=socketChannel.read(mappedByteBuffer);
      }
      if (tranfered > 0) {
        byte[] data=new byte[tranfered];
        mappedByteBuffer.flip();
        mappedByteBuffer.get(data,0,tranfered);
        if (isNested)         handler.handleReadEvent(parent,data);
 else         handler.handleReadEvent(this,data);
        break;
      }
 else       if (tranfered == 0) {
        LOGGER.warn("String_Node_Str",tranfered);
        if (!this.socketChannel.isOpen()) {
          this.close("String_Node_Str");
          return;
        }
        this.mappedByteBuffer.clear();
      }
 else {
        this.close("String_Node_Str");
        return;
      }
    }
  }
  finally {
    rwLock.set(false);
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @Override public void asynRead() throws IOException {
  if (isClosed.get()) {
    return;
  }
  if (!rwLock.compareAndSet(false,true)) {
    return;
  }
  lastReadTime=TimeUtil.currentTimeMillis();
  try {
    for (; ; ) {
      int position=mappedByteBuffer.position();
      int count=MAPPED_SIZE - position;
      int tranfered=(int)fileChannel.transferFrom(socketChannel,position,count);
      mappedByteBuffer.position(position + tranfered);
      if (tranfered == 0 && count > 0) {
        tranfered=socketChannel.read(mappedByteBuffer);
      }
      if (tranfered > 0) {
        netInBytes+=tranfered;
        netInCounter++;
        byte[] data=new byte[tranfered];
        mappedByteBuffer.flip();
        mappedByteBuffer.get(data,0,tranfered);
        if (isNested)         handler.handleReadEvent(parent,data);
 else         handler.handleReadEvent(this,data);
        break;
      }
 else       if (tranfered == 0) {
        LOGGER.warn("String_Node_Str",tranfered);
        if (!this.socketChannel.isOpen()) {
          this.close("String_Node_Str");
          return;
        }
        this.mappedByteBuffer.clear();
      }
 else {
        this.close("String_Node_Str");
        return;
      }
    }
  }
  finally {
    rwLock.set(false);
  }
}
Program: 37493
Project: 37493
Buggy source:
@Override public String toString(){
  StringBuffer sbuffer=new StringBuffer(100);
  sbuffer.append("String_Node_Str");
  sbuffer.append("String_Node_Str").append(reactor);
  sbuffer.append("String_Node_Str").append(host);
  sbuffer.append("String_Node_Str").append(port);
  sbuffer.append("String_Node_Str").append(id);
  sbuffer.append("String_Node_Str").append(startupTime);
  sbuffer.append("String_Node_Str").append(lastReadTime);
  sbuffer.append("String_Node_Str").append(lastWriteTime);
  sbuffer.append("String_Node_Str").append(writeAttempts);
  sbuffer.append("String_Node_Str").append(netInCounter).append("String_Node_Str").append(netOutCounter);
  if (isClosed.get()) {
    sbuffer.append("String_Node_Str").append(isClosed);
    sbuffer.append("String_Node_Str").append(closeTime);
    sbuffer.append("String_Node_Str").append(closeReason);
  }
  sbuffer.append("String_Node_Str");
  return sbuffer.toString();
}

Fixed version (ground truth):
@Override public String toString(){
  StringBuffer sbuffer=new StringBuffer(100);
  sbuffer.append("String_Node_Str");
  sbuffer.append("String_Node_Str").append(reactor);
  sbuffer.append("String_Node_Str").append(host).append("String_Node_Str").append(port);
  sbuffer.append("String_Node_Str").append(id);
  sbuffer.append("String_Node_Str").append(startupTime);
  sbuffer.append("String_Node_Str").append(lastReadTime);
  sbuffer.append("String_Node_Str").append(lastWriteTime);
  sbuffer.append("String_Node_Str").append(writeAttempts);
  sbuffer.append("String_Node_Str").append(netInCounter).append("String_Node_Str").append(netOutCounter);
  if (isClosed.get()) {
    sbuffer.append("String_Node_Str").append(isClosed);
    sbuffer.append("String_Node_Str").append(closeTime);
    sbuffer.append("String_Node_Str").append(closeReason);
  }
  sbuffer.append("String_Node_Str");
  return sbuffer.toString();
}
Program: 37494
Project: 37494
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);
      }
      write0(position,count);
    }
 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;
      }
      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());
      }
 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);
  }
}
Program: 37495
Project: 37495
Buggy source:
private void sendCommand(final RedisOutputStream os,final byte[]... args){
  try {
    os.write(ASTERISK_BYTE);
    os.writeIntCrLf(args.length);
    os.writeCrLf();
    for (    final byte[] arg : args) {
      os.write(DOLLAR_BYTE);
      os.writeIntCrLf(arg.length);
      os.write(arg);
      os.writeCrLf();
    }
  }
 catch (  IOException e) {
    throw new JedisConnectionException(e);
  }
}

Fixed version (ground truth):
private void sendCommand(final RedisOutputStream os,final byte[]... args){
  try {
    os.write(ASTERISK_BYTE);
    os.writeIntCrLf(args.length);
    for (    final byte[] arg : args) {
      os.write(DOLLAR_BYTE);
      os.writeIntCrLf(arg.length);
      os.write(arg);
      os.writeCrLf();
    }
  }
 catch (  IOException e) {
    throw new JedisConnectionException(e);
  }
}
Program: 37496
Project: 37496
Buggy source:
@Override public void write(ByteBuffer buf){
  writeQueue.offer(buf);
  try {
    for (; ; ) {
      if (!rwLock.compareAndSet(false,true)) {
        break;
      }
    }
    ByteBuffer tmpBuf;
    while ((tmpBuf=writeQueue.poll()) != null) {
      mappedByteBuffer.clear();
      int position=0;
      int count=fileChannel.write(tmpBuf,position);
      if (tmpBuf.hasRemaining()) {
        throw new IOException("String_Node_Str" + count + "String_Node_Str"+ tmpBuf.remaining());
      }
      write0(position,count);
    }
  }
 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){
  buf.flip();
  writeQueue.offer(buf);
  try {
    for (; ; ) {
      if (!rwLock.compareAndSet(false,true)) {
        break;
      }
    }
    ByteBuffer tmpBuf;
    while ((tmpBuf=writeQueue.poll()) != null) {
      mappedByteBuffer.clear();
      int position=0;
      int count=fileChannel.write(tmpBuf,position);
      if (tmpBuf.hasRemaining()) {
        throw new IOException("String_Node_Str" + count + "String_Node_Str"+ tmpBuf.remaining());
      }
      write0(position,count);
    }
  }
 catch (  IOException e) {
    LOGGER.error("String_Node_Str",e);
    this.close("String_Node_Str" + e);
  }
 finally {
    rwLock.set(false);
  }
}
Program: 37497
Project: 37497
Buggy source:
public List<RedisResponse> writeToBackend(RedisRequest request){
  JedisPool jedisPool=JedisHolder.INSTANCE().getJedisPool(host,port);
  JedisConnection jedisConn=jedisPool.getResource();
  try {
    jedisConn.sendCommand(request.getArgs());
    byte[] response=jedisConn.getBinaryReply();
    RedisResponseDecoder decoder=new RedisResponseDecoder();
    return decoder.decode(response);
  }
 catch (  Exception e) {
    LOGGER.error("String_Node_Str" + host + "String_Node_Str"+ port,e);
  }
 finally {
    if (jedisConn != null) {
      jedisConn.close();
    }
  }
  return null;
}

Fixed version (ground truth):
public List<RedisResponse> writeToBackend(RedisRequest request){
  JedisPool jedisPool=JedisHolder.INSTANCE().getJedisPool(host,port);
  JedisConnection jedisConn=jedisPool.getResource();
  try {
    jedisConn.sendCommand(request.getArgs());
    byte[] response=jedisConn.getBinaryReply();
    RedisResponseDecoder decoder=new RedisResponseDecoder();
    List<RedisResponse> result=decoder.decode(response);
    while (result == null) {
      response=jedisConn.getBinaryReply();
      result=decoder.decode(response);
    }
    return result;
  }
 catch (  Exception e) {
    LOGGER.error("String_Node_Str" + host + "String_Node_Str"+ port,e);
  }
 finally {
    if (jedisConn != null) {
      jedisConn.close();
    }
  }
  return null;
}
Program: 37498
Project: 37498
Buggy source:
@Override public void onCollect(String password,String cmd,String key,int requestSize,int responseSize,int procTimeMills,int waitTimeMills,boolean isCommandOnly){
  if (isCommandOnly)   return;
  if (requestSize < REQUIRED_SIZE && responseSize < REQUIRED_SIZE) {
    return;
  }
  if (!locking.compareAndSet(false,true)) {
    return;
  }
  try {
    if (bkList.size() >= LENGTH) {
      while (bkList.size() >= (LENGTH * 0.5)) {
        int index=bkList.size() - 1;
        BigKey bk=bkList.remove(index);
        if (bk != null) {
          bkHashMap.remove(bk.key);
        }
      }
    }
    BigKey newBK=new BigKey();
    newBK.key=key;
    int index=bkList.indexOf(newBK);
    if (index >= 0) {
      BigKey oldBK=bkHashMap.get(key);
      oldBK.lastCmd=cmd;
      oldBK.size=requestSize > responseSize ? requestSize : responseSize;
      oldBK.lastUseTime=TimeUtil.currentTimeMillis();
      oldBK.count.incrementAndGet();
      oldBK.fromReq=requestSize >= REQUIRED_SIZE;
      oldBK.fromResp=responseSize >= REQUIRED_SIZE;
    }
 else {
      newBK.lastCmd=cmd;
      newBK.size=requestSize > responseSize ? requestSize : responseSize;
      newBK.lastUseTime=TimeUtil.currentTimeMillis();
      newBK.fromReq=requestSize >= REQUIRED_SIZE;
      newBK.fromResp=responseSize >= REQUIRED_SIZE;
      bkList.add(newBK);
      bkHashMap.put(key,newBK);
    }
  }
  finally {
    locking.set(false);
  }
}

Fixed version (ground truth):
@Override public void onCollect(String password,String cmd,String key,int requestSize,int responseSize,int procTimeMills,int waitTimeMills,boolean isCommandOnly){
  if (isCommandOnly)   return;
  if (requestSize < REQUIRED_SIZE && responseSize < REQUIRED_SIZE) {
    return;
  }
  if (!locking.compareAndSet(false,true)) {
    return;
  }
  try {
    if (bkList.size() >= LENGTH) {
      while (bkList.size() >= (LENGTH * 0.5)) {
        int index=bkList.size() - 1;
        BigKey bk=bkList.remove(index);
        if (bk != null) {
          bkHashMap.remove(bk.key);
        }
      }
    }
    BigKey newBK=new BigKey();
    newBK.key=key;
    int index=bkList.indexOf(newBK);
    if (index >= 0) {
      BigKey oldBK=bkHashMap.get(key);
      if (oldBK == null) {
        oldBK=newBK;
        bkHashMap.put(key,oldBK);
      }
      oldBK.lastCmd=cmd;
      oldBK.size=requestSize > responseSize ? requestSize : responseSize;
      oldBK.lastUseTime=TimeUtil.currentTimeMillis();
      oldBK.count.incrementAndGet();
      oldBK.fromReq=requestSize >= REQUIRED_SIZE;
      oldBK.fromResp=responseSize >= REQUIRED_SIZE;
    }
 else {
      newBK.lastCmd=cmd;
      newBK.size=requestSize > responseSize ? requestSize : responseSize;
      newBK.lastUseTime=TimeUtil.currentTimeMillis();
      newBK.fromReq=requestSize >= REQUIRED_SIZE;
      newBK.fromResp=responseSize >= REQUIRED_SIZE;
      bkList.add(newBK);
      bkHashMap.put(key,newBK);
    }
  }
  finally {
    locking.set(false);
  }
}
Program: 37499
Project: 37499
Buggy source:
@Override public String toString(){
  StringBuffer sbuffer=new StringBuffer(100);
  sbuffer.append("String_Node_Str");
  sbuffer.append("String_Node_Str").append(delegateConn.toString());
  sbuffer.append("String_Node_Str").append(borrowed);
  if (heartbeatTime > 0) {
    sbuffer.append("String_Node_Str").append(heartbeatTime);
  }
  sbuffer.append("String_Node_Str").append(isZeroCopy);
  return sbuffer.toString();
}

Fixed version (ground truth):
@Override public String toString(){
  StringBuffer sbuffer=new StringBuffer(100);
  sbuffer.append(delegateConn.toString());
  sbuffer.append("String_Node_Str");
  sbuffer.append("String_Node_Str").append(borrowed);
  sbuffer.append("String_Node_Str").append(isZeroCopy);
  if (heartbeatTime > 0) {
    sbuffer.append("String_Node_Str").append(heartbeatTime);
  }
  sbuffer.append("String_Node_Str");
  return sbuffer.toString();
}
Program: 37500
Project: 37500
Buggy source:
@Override public void write(ByteBuffer buf){
  try {
    for (; ; ) {
      if (!rwLock.compareAndSet(false,true)) {
        break;
      }
    }
    buf.flip();
    if (buf.limit() <= BUF_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());
      }
      write0(position,count);
    }
 else {
      int bufSize=buf.limit();
      int cnt=(bufSize / BUF_SIZE) + (bufSize % BUF_SIZE > 0 ? 1 : 0);
      int postion=0;
      for (int i=0; i < cnt; i++) {
        int limit=BUF_SIZE * i;
        if (limit > bufSize) {
          limit=bufSize - postion;
        }
        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;
      }
    }
  }
 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 <= BUF_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());
      }
      write0(position,count);
    }
 else {
      int cnt=(bufSize / BUF_SIZE) + (bufSize % BUF_SIZE > 0 ? 1 : 0);
      int postion=0;
      for (int i=1; i <= cnt; i++) {
        int limit=BUF_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;
      }
    }
  }
 catch (  IOException e) {
    LOGGER.error("String_Node_Str",e);
    this.close("String_Node_Str" + e);
  }
 finally {
    rwLock.set(false);
  }
}
Program: 37501
Project: 37501
Buggy source:
@Override public void setHandler(NIOHandler<? extends ClosableConnection> handler){
  delegateConn.setHandler(handler);
}

Fixed version (ground truth):
@Override public void setHandler(NIOHandler<? extends ClosableConnection> handler){
  this.delegateConn.setHandler(handler);
}
Program: 37502
Project: 37502
Buggy source:
@Override public void close(String reason){
  delegateConn.close(reason);
}

Fixed version (ground truth):
@Override public void close(String reason){
  delegateConn.close(reason);
  delegateConn.setNested(false);
  delegateConn.setParent(null);
}
Program: 37503
Project: 37503
Buggy source:
public BackendConnection(boolean isZeroCopy,SocketChannel socketChannel){
  if (isZeroCopy) {
    delegateConn=new ZeroCopyConnection(socketChannel);
  }
 else {
    delegateConn=new Connection(socketChannel);
  }
  this.isZeroCopy=true;
}

Fixed version (ground truth):
public BackendConnection(boolean isZeroCopy,SocketChannel socketChannel){
  if (isZeroCopy) {
    delegateConn=new ZeroCopyConnection(socketChannel);
  }
 else {
    delegateConn=new Connection(socketChannel);
  }
  delegateConn.setParent(this);
  delegateConn.setNested(true);
  this.isZeroCopy=true;
}
Program: 37504
Project: 37504
Buggy source:
@Override public String toString(){
  StringBuffer sbuffer=new StringBuffer(100);
  sbuffer.append("String_Node_Str").append(reactor);
  sbuffer.append("String_Node_Str").append(delegateConn.toString());
  sbuffer.append("String_Node_Str").append(borrowed);
  if (heartbeatTime > 0) {
    sbuffer.append("String_Node_Str").append(heartbeatTime);
  }
  sbuffer.append("String_Node_Str").append(isZeroCopy);
  return sbuffer.toString();
}

Fixed version (ground truth):
@Override public String toString(){
  StringBuffer sbuffer=new StringBuffer(100);
  sbuffer.append("String_Node_Str");
  sbuffer.append("String_Node_Str").append(delegateConn.toString());
  sbuffer.append("String_Node_Str").append(borrowed);
  if (heartbeatTime > 0) {
    sbuffer.append("String_Node_Str").append(heartbeatTime);
  }
  sbuffer.append("String_Node_Str").append(isZeroCopy);
  return sbuffer.toString();
}
Program: 37505
Project: 37505
Buggy source:
@SuppressWarnings("String_Node_Str") public void close(String reason){
  if (!isClosed.get()) {
    closeSocket();
    isClosed.set(true);
    this.closeTime=TimeUtil.currentTimeMillis();
    if (reason != null)     this.closeReason=reason;
    this.cleanup();
    NetSystem.getInstance().removeConnection(this);
    if (LOGGER.isDebugEnabled()) {
      LOGGER.debug("String_Node_Str" + reason + "String_Node_Str"+ this.toString());
    }
    if (handler != null) {
      handler.onClosed(this,reason);
    }
    this.attachement=null;
  }
 else {
    this.cleanup();
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public void close(String reason){
  if (!isClosed.get()) {
    closeSocket();
    isClosed.set(true);
    this.closeTime=TimeUtil.currentTimeMillis();
    if (reason != null)     this.closeReason=reason;
    this.cleanup();
    if (isNested) {
      NetSystem.getInstance().removeConnection(parent);
      if (handler != null)       handler.onClosed(parent,reason);
    }
 else {
      NetSystem.getInstance().removeConnection(this);
      if (handler != null)       handler.onClosed(this,reason);
    }
    if (LOGGER.isDebugEnabled()) {
      LOGGER.debug("String_Node_Str" + reason + "String_Node_Str"+ this.toString());
    }
    this.attachement=null;
  }
 else {
    this.cleanup();
  }
}
Program: 37506
Project: 37506
Buggy source:
@SuppressWarnings("String_Node_Str") public void register(Selector selector) throws IOException {
  try {
    processKey=socketChannel.register(selector,SelectionKey.OP_READ,this);
    if (LOGGER.isDebugEnabled()) {
      LOGGER.debug("String_Node_Str" + this);
    }
    this.setState(Connection.STATE_CONNECTED);
    NetSystem.getInstance().addConnection(this);
    this.handler.onConnected(this);
  }
  finally {
    if (isClosed()) {
      clearSelectionKey();
    }
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public void register(Selector selector) throws IOException {
  try {
    processKey=socketChannel.register(selector,SelectionKey.OP_READ,this);
    if (LOGGER.isDebugEnabled()) {
      LOGGER.debug("String_Node_Str" + this);
    }
    this.setState(Connection.STATE_CONNECTED);
    if (isNested) {
      NetSystem.getInstance().addConnection(parent);
      this.handler.onConnected(parent);
    }
 else {
      NetSystem.getInstance().addConnection(this);
      this.handler.onConnected(this);
    }
  }
  finally {
    if (isClosed()) {
      clearSelectionKey();
    }
  }
}
Program: 37508
Project: 37508
Buggy source:
@Override public void doNextWriteCheck(){
  if (!writing.compareAndSet(false,true)) {
    return;
  }
  if (writeQueue.isEmpty()) {
    return;
  }
  try {
    boolean noMoreData=write0();
    if (noMoreData && writeQueue.isEmpty()) {
      if ((processKey.isValid() && (processKey.interestOps() & SelectionKey.OP_WRITE) != 0)) {
        disableWrite();
      }
    }
 else {
      if ((processKey.isValid() && (processKey.interestOps() & SelectionKey.OP_WRITE) == 0)) {
        enableWrite(false);
      }
    }
  }
 catch (  IOException e) {
    if (LOGGER.isDebugEnabled()) {
      LOGGER.debug("String_Node_Str",e);
    }
    close("String_Node_Str" + e);
  }
 finally {
    writing.set(false);
  }
}

Fixed version (ground truth):
@Override public void doNextWriteCheck(){
  if (writeQueue.isEmpty()) {
    return;
  }
  if (!writing.compareAndSet(false,true)) {
    return;
  }
  try {
    boolean noMoreData=write0();
    if (noMoreData && writeQueue.isEmpty()) {
      if ((processKey.isValid() && (processKey.interestOps() & SelectionKey.OP_WRITE) != 0)) {
        disableWrite();
      }
    }
 else {
      if ((processKey.isValid() && (processKey.interestOps() & SelectionKey.OP_WRITE) == 0)) {
        enableWrite(false);
      }
    }
  }
 catch (  IOException e) {
    if (LOGGER.isDebugEnabled()) {
      LOGGER.debug("String_Node_Str",e);
    }
    close("String_Node_Str" + e);
  }
 finally {
    writing.set(false);
  }
}
Program: 37509
Project: 37509
Buggy source:
private void processPendingQueue(Selector selector){
  ClosableConnection c=null;
  while ((c=pendingQueue.poll()) != null) {
    try {
      c.register(selector);
    }
 catch (    Exception e) {
      LOGGER.warn("String_Node_Str",e);
      c.close("String_Node_Str");
    }
  }
}

Fixed version (ground truth):
private void processPendingQueue(Selector selector){
  ClosableConnection c=null;
  while ((c=pendingQueue.poll()) != null) {
    try {
      c.register(selector);
    }
 catch (    Exception e) {
      c.close("String_Node_Str");
    }
  }
}
Program: 37510
Project: 37510
Buggy source:
@SuppressWarnings("String_Node_Str") @Override public void asynRead() throws IOException {
  if (isClosed.get()) {
    return;
  }
  if (!rwLock.compareAndSet(false,true)) {
    return;
  }
  lastReadTime=TimeUtil.currentTimeMillis();
  try {
    for (; ; ) {
      int position=mappedByteBuffer.position();
      int count=BUF_SIZE - position;
      int tranfered=(int)fileChannel.transferFrom(socketChannel,position,count);
      mappedByteBuffer.position(position + tranfered);
      if (tranfered == 0 && count > 0) {
        tranfered=socketChannel.read(mappedByteBuffer);
      }
      if (tranfered > 0) {
        byte[] data=new byte[tranfered];
        mappedByteBuffer.flip();
        mappedByteBuffer.get(data,0,tranfered);
        System.out.println("String_Node_Str" + tranfered + "String_Node_Str"+ new String(data));
        handler.handleReadEvent(this,data);
        break;
      }
 else       if (tranfered == 0) {
        LOGGER.warn("String_Node_Str",tranfered);
        if (!this.socketChannel.isOpen()) {
          this.close("String_Node_Str");
          return;
        }
        this.mappedByteBuffer.clear();
      }
 else {
        this.close("String_Node_Str");
        return;
      }
    }
  }
  finally {
    rwLock.set(false);
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @Override public void asynRead() throws IOException {
  if (isClosed.get()) {
    return;
  }
  if (!rwLock.compareAndSet(false,true)) {
    return;
  }
  lastReadTime=TimeUtil.currentTimeMillis();
  try {
    for (; ; ) {
      int position=mappedByteBuffer.position();
      int count=BUF_SIZE - position;
      int tranfered=(int)fileChannel.transferFrom(socketChannel,position,count);
      mappedByteBuffer.position(position + tranfered);
      if (tranfered == 0 && count > 0) {
        tranfered=socketChannel.read(mappedByteBuffer);
      }
      if (tranfered > 0) {
        byte[] data=new byte[tranfered];
        mappedByteBuffer.flip();
        mappedByteBuffer.get(data,0,tranfered);
        System.out.println("String_Node_Str" + tranfered + "String_Node_Str"+ new String(data));
        if (isNested)         handler.handleReadEvent(parent,data);
 else         handler.handleReadEvent(this,data);
        break;
      }
 else       if (tranfered == 0) {
        LOGGER.warn("String_Node_Str",tranfered);
        if (!this.socketChannel.isOpen()) {
          this.close("String_Node_Str");
          return;
        }
        this.mappedByteBuffer.clear();
      }
 else {
        this.close("String_Node_Str");
        return;
      }
    }
  }
  finally {
    rwLock.set(false);
  }
}
Program: 37511
Project: 37511
Buggy source:
private void connect(Selector selector){
  ClosableConnection c=null;
  while ((c=connectQueue.poll()) != null) {
    try {
      SocketChannel channel=(SocketChannel)c.getSocketChannel();
      channel.register(selector,SelectionKey.OP_CONNECT,c);
      channel.connect(new InetSocketAddress(c.host,c.port));
    }
 catch (    Exception e) {
      LOGGER.error("String_Node_Str",e);
      c.close("String_Node_Str" + e.toString());
    }
  }
}

Fixed version (ground truth):
private void connect(Selector selector){
  ClosableConnection c=null;
  while ((c=connectQueue.poll()) != null) {
    try {
      SocketChannel channel=(SocketChannel)c.getSocketChannel();
      channel.register(selector,SelectionKey.OP_CONNECT,c);
      channel.connect(new InetSocketAddress(c.getHost(),c.getPort()));
    }
 catch (    Exception e) {
      LOGGER.error("String_Node_Str",e);
      c.close("String_Node_Str" + e.toString());
    }
  }
}
Program: 37512
Project: 37512
Buggy source:
/** 
 * 异步读取,该方法在 reactor 中被调用
 */
@SuppressWarnings("String_Node_Str") @Override protected void asynRead() throws IOException {
  if (isClosed.get()) {
    return;
  }
  if (!rwLock.compareAndSet(false,true)) {
    return;
  }
  lastReadTime=TimeUtil.currentTimeMillis();
  rewind();
  try {
    for (; ; ) {
      final int position=mappedByteBuffer.position();
      final int count=totalSize - position;
      int tranfered=(int)fileChannel.transferFrom(channel,position,count);
      mappedByteBuffer.position(position + tranfered);
      if (tranfered == 0 && count > 0) {
        tranfered=channel.read(mappedByteBuffer);
      }
      if (tranfered > 0) {
        int oldPos=mappedByteBuffer.position();
        mappedByteBuffer.position(0);
        ByteBuffer copyBuf=mappedByteBuffer.slice();
        copyBuf.limit(tranfered);
        byte[] data=new byte[tranfered];
        copyBuf.get(data);
        mappedByteBuffer.position(oldPos);
        System.out.println("String_Node_Str" + tranfered + "String_Node_Str"+ new String(data));
        handler.handleReadEvent(this,data);
        break;
      }
 else       if (tranfered == 0) {
        if (!this.channel.isOpen()) {
          this.close("String_Node_Str");
          return;
        }
      }
 else {
        this.close("String_Node_Str");
        return;
      }
    }
  }
  finally {
    rwLock.set(false);
  }
}

Fixed version (ground truth):
/** 
 * 异步读取,该方法在 reactor 中被调用
 */
@SuppressWarnings("String_Node_Str") @Override protected void asynRead() throws IOException {
  if (isClosed.get()) {
    return;
  }
  if (!rwLock.compareAndSet(false,true)) {
    return;
  }
  lastReadTime=TimeUtil.currentTimeMillis();
  rewind();
  try {
    for (; ; ) {
      final int position=mappedByteBuffer.position();
      final int count=totalSize - position;
      int tranfered=(int)fileChannel.transferFrom(channel,position,count);
      mappedByteBuffer.position(position + tranfered);
      if (tranfered == 0 && count > 0) {
        tranfered=channel.read(mappedByteBuffer);
      }
      if (tranfered > 0) {
        int oldPos=mappedByteBuffer.position();
        mappedByteBuffer.position(position);
        ByteBuffer copyBuf=mappedByteBuffer.slice();
        copyBuf.limit(tranfered);
        byte[] data=new byte[tranfered];
        copyBuf.get(data);
        mappedByteBuffer.position(oldPos);
        System.out.println("String_Node_Str" + tranfered + "String_Node_Str"+ new String(data));
        handler.handleReadEvent(this,data);
        break;
      }
 else       if (tranfered == 0) {
        if (!this.channel.isOpen()) {
          this.close("String_Node_Str");
          return;
        }
      }
 else {
        this.close("String_Node_Str");
        return;
      }
    }
  }
  finally {
    rwLock.set(false);
  }
}
Program: 37513
Project: 37513
Buggy source:
private void write0(int position,int count) throws IOException {
  int writed=(int)fileChannel.transferTo(position,count,channel);
  boolean noMoreData=writed == count;
  if (noMoreData) {
    if ((processKey.isValid() && (processKey.interestOps() & SelectionKey.OP_WRITE) != 0)) {
      disableWrite();
    }
  }
 else {
    if ((processKey.isValid() && (processKey.interestOps() & SelectionKey.OP_WRITE) == 0)) {
      enableWrite(false);
    }
  }
}

Fixed version (ground truth):
private void write0(int position,int count) throws IOException {
  int tranfered=(int)fileChannel.transferTo(position,count,channel);
  boolean noMoreData=tranfered == count;
  if (noMoreData) {
    if ((processKey.isValid() && (processKey.interestOps() & SelectionKey.OP_WRITE) != 0)) {
      disableWrite();
    }
  }
 else {
    if ((processKey.isValid() && (processKey.interestOps() & SelectionKey.OP_WRITE) == 0)) {
      enableWrite(false);
    }
  }
}
Program: 37514
Project: 37514
Buggy source:
public static void main(String[] args) throws IOException {
  Log4jInitializer.configureAndWatch(System.getProperty("String_Node_Str"),"String_Node_Str",30000L);
  String name="String_Node_Str";
  String bindIp="String_Node_Str";
  int port=8066;
  ConnectionFactory factory=new ZeroCopyConnectionFactory();
  NIOReactorPool reactorPool=new NIOReactorPool("String_Node_Str",8);
  final NIOAcceptor acceptor=new NIOAcceptor(name,bindIp,port,factory,reactorPool);
  acceptor.start();
}

Fixed version (ground truth):
public static void main(String[] args) throws IOException {
  Log4jInitializer.configureAndWatch(System.getProperty("String_Node_Str"),"String_Node_Str",30000L);
  BufferPool bufferPool=new BucketBufferPool(1024 * 1024 * 40,1024 * 1024 * 80,1024 * 16,1024,new int[]{1024},1024 * 32,3);
  new NetSystem(bufferPool,ExecutorUtil.create("String_Node_Str",2),ExecutorUtil.create("String_Node_Str",2));
  String name="String_Node_Str";
  String bindIp="String_Node_Str";
  int port=8066;
  ConnectionFactory factory=new ZeroCopyConnectionFactory();
  NIOReactorPool reactorPool=new NIOReactorPool("String_Node_Str",8);
  final NIOAcceptor acceptor=new NIOAcceptor(name,bindIp,port,factory,reactorPool);
  acceptor.start();
}
Program: 37516
Project: 37516
Buggy source:
/** 
 * 定时执行该方法，回收部分资源。
 */
public void checkConnections(){
  Iterator<Entry<Long,AbstractConnection>> it=allConnections.entrySet().iterator();
  while (it.hasNext()) {
    AbstractConnection c=it.next().getValue();
    if (c == null) {
      it.remove();
      continue;
    }
    if (c instanceof RedisBackendConnection) {
      RedisBackendConnection backendCon=(RedisBackendConnection)c;
      if (backendCon.isBorrowed() && backendCon.getLastTime() < TimeUtil.currentTimeMillis() - TIMEOUT) {
        StringBuffer errBuffer=new StringBuffer();
        errBuffer.append("String_Node_Str").append(c);
        if (c.getAttachement() != null) {
          errBuffer.append("String_Node_Str").append(c.getAttachement());
        }
        errBuffer.append("String_Node_Str").append(backendCon.getChannel().isConnected());
        errBuffer.append("String_Node_Str").append(backendCon.getChannel().isBlocking());
        errBuffer.append("String_Node_Str").append(backendCon.getChannel().isOpen());
        errBuffer.append("String_Node_Str").append(backendCon.getChannel().socket().isConnected());
        errBuffer.append("String_Node_Str").append(backendCon.getChannel().socket().isClosed());
        LOGGER.warn(errBuffer.toString());
        c.close("String_Node_Str");
      }
    }
    if (c.isClosed()) {
      it.remove();
    }
 else {
      if (c.isConnected() && !c.writeQueue.isEmpty()) {
        c.doNextWriteCheck();
      }
      c.idleCheck();
    }
  }
}

Fixed version (ground truth):
/** 
 * 定时执行该方法，回收部分资源。
 */
public void checkConnections(){
  Iterator<Entry<Long,AbstractConnection>> it=allConnections.entrySet().iterator();
  while (it.hasNext()) {
    AbstractConnection c=it.next().getValue();
    if (c == null) {
      it.remove();
      continue;
    }
    if (c instanceof BackendConnection) {
      BackendConnection backendCon=(BackendConnection)c;
      if (backendCon.isBorrowed() && backendCon.getLastTime() < TimeUtil.currentTimeMillis() - TIMEOUT) {
        StringBuffer errBuffer=new StringBuffer();
        errBuffer.append("String_Node_Str").append(c);
        if (c.getAttachement() != null) {
          errBuffer.append("String_Node_Str").append(c.getAttachement());
        }
        errBuffer.append("String_Node_Str").append(backendCon.getChannel().isConnected());
        errBuffer.append("String_Node_Str").append(backendCon.getChannel().isBlocking());
        errBuffer.append("String_Node_Str").append(backendCon.getChannel().isOpen());
        errBuffer.append("String_Node_Str").append(backendCon.getChannel().socket().isConnected());
        errBuffer.append("String_Node_Str").append(backendCon.getChannel().socket().isClosed());
        LOGGER.warn(errBuffer.toString());
        c.close("String_Node_Str");
      }
    }
    if (c.isClosed()) {
      it.remove();
    }
 else {
      if (c.isConnected() && !c.writeQueue.isEmpty()) {
        c.doNextWriteCheck();
      }
      c.idleCheck();
    }
  }
}
Program: 37517
Project: 37517
Buggy source:
private void initRunning(){
  if (!isStart()) {
    return;
  }
  byte[] bytes=JsonUtils.marshalToByte(serverData);
  try {
    mutex.set(false);
    zkClient.create(path,bytes,CreateMode.EPHEMERAL);
    activeData=serverData;
    processActiveEnter();
    mutex.set(true);
  }
 catch (  ZkNodeExistsException e) {
    bytes=zkClient.readData(path,true);
    if (bytes == null) {
      initRunning();
    }
 else {
      activeData=JsonUtils.unmarshalFromByte(bytes,ServerRunningData.class);
    }
  }
catch (  ZkNoNodeException e) {
    zkClient.createPersistent(path,true);
    initRunning();
  }
}

Fixed version (ground truth):
private void initRunning(){
  if (!isStart()) {
    return;
  }
  byte[] bytes=JsonUtils.marshalToByte(serverData);
  try {
    mutex.set(false);
    zkClient.create(path,bytes,CreateMode.EPHEMERAL);
    activeData=serverData;
    processActiveEnter();
    mutex.set(true);
  }
 catch (  ZkNodeExistsException e) {
    bytes=zkClient.readData(path,true);
    if (bytes == null) {
      initRunning();
    }
 else {
      activeData=JsonUtils.unmarshalFromByte(bytes,ServerRunningData.class);
    }
  }
catch (  ZkNoNodeException e) {
    if (path.lastIndexOf(File.separator) > 0) {
      String fatherPath=path.substring(0,path.lastIndexOf(File.separator));
      zkClient.createPersistent(fatherPath,true);
      initRunning();
    }
 else {
      LOGGER.error("String_Node_Str" + path + "String_Node_Str",e);
    }
  }
}
Program: 37518
Project: 37518
Buggy source:
@Override public void reloadExtraCfg() throws Exception {
  Map<String,TopicCfg> newTopicCfgMap=KafkaConfigLoader.loadTopicCfgMap(this.id,ConfigLoader.buidCfgAbsPathFor("String_Node_Str"));
  KafkaCtx.getInstance().load(newTopicCfgMap,this);
  Map<String,TopicCfg> oldTopicCfgMap=topicCfgMap;
  for (  TopicCfg newTopicCfg : newTopicCfgMap.values()) {
    TopicCfg oldTopicCfg=oldTopicCfgMap.get(newTopicCfg.getName());
    if (oldTopicCfg != null) {
      for (      BrokerPartition newPartition : newTopicCfg.getRunningOffset().getPartitions().values()) {
        BrokerPartition oldPartition=oldTopicCfg.getRunningOffset().getPartition(newPartition.getPartition());
        if (oldPartition != null) {
          newPartition.setProducerConsumerOffset(oldPartition.getProducerConsumerOffset());
        }
 else {
        }
      }
    }
  }
}

Fixed version (ground truth):
@Override public void reloadExtraCfg() throws Exception {
  Map<String,TopicCfg> newTopicCfgMap=KafkaConfigLoader.loadTopicCfgMap(this.id,ConfigLoader.buidCfgAbsPathFor("String_Node_Str"));
  KafkaCtx.getInstance().load(newTopicCfgMap,this);
  Map<String,TopicCfg> oldTopicCfgMap=topicCfgMap;
  for (  TopicCfg newTopicCfg : newTopicCfgMap.values()) {
    TopicCfg oldTopicCfg=oldTopicCfgMap.get(newTopicCfg.getName());
    if (oldTopicCfg != null) {
      for (      BrokerPartition newPartition : newTopicCfg.getRunningOffset().getPartitions().values()) {
        BrokerPartition oldPartition=oldTopicCfg.getRunningOffset().getPartition(newPartition.getPartition());
        if (oldPartition != null) {
          newPartition.setProducerConsumerOffset(oldPartition.getProducerConsumerOffset());
        }
 else {
        }
      }
    }
  }
  this.topicCfgMap=newTopicCfgMap;
}
Program: 37519
Project: 37519
Buggy source:
public byte[] reloadAll(){
  try {
    Map<Integer,PoolCfg> poolCfgMap=RedisEngineCtx.INSTANCE().getPoolCfgMap();
    for (    Entry<Integer,PoolCfg> entry : poolCfgMap.entrySet()) {
      PoolCfg poolCfg=entry.getValue();
      if (poolCfg instanceof KafkaPoolCfg)       poolCfg.reloadExtraCfg();
    }
  }
 catch (  Exception e) {
    LOGGER.error("String_Node_Str",e);
    StringBuffer sb=new StringBuffer();
    sb.append("String_Node_Str").append(e.getMessage()).append("String_Node_Str");
    return sb.toString().getBytes();
  }
 finally {
    lock.unlock();
  }
  return "String_Node_Str".getBytes();
}

Fixed version (ground truth):
public byte[] reloadAll(){
  try {
    Map<Integer,PoolCfg> poolCfgMap=RedisEngineCtx.INSTANCE().getPoolCfgMap();
    for (    PoolCfg poolCfg : poolCfgMap.values()) {
      if (poolCfg instanceof KafkaPoolCfg)       poolCfg.reloadExtraCfg();
    }
  }
 catch (  Exception e) {
    LOGGER.error("String_Node_Str",e);
    StringBuffer sb=new StringBuffer();
    sb.append("String_Node_Str").append(e.getMessage()).append("String_Node_Str");
    return sb.toString().getBytes();
  }
 finally {
    lock.unlock();
  }
  return "String_Node_Str".getBytes();
}