Program: 175721
Project: 175721
Buggy source:
public long append(byte[] messageContent){
  boolean isNeedNewSegmentFile=false;
  int segmentSize=startOffsetSegmentMap.size();
  try {
    if (segmentSize == 0) {
      isNeedNewSegmentFile=true;
    }
 else {
      Segment lastSegment=startOffsetSegmentMap.lastEntry().getValue();
      if (!lastSegment.isCanWrite()) {
        isNeedNewSegmentFile=true;
      }
 else {
        int maxSegmentSize=GlobalConf.getInstance().getMaxSegmentSize();
        if (lastSegment.getFileSize() + messageContent.length > maxSegmentSize) {
          isNeedNewSegmentFile=true;
          lastSegment.close();
          lastSegment.setCanWrite(false);
          String newFileName=String.format("String_Node_Str",lastSegment.getStartOffset(),lastSegment.getEndOffset());
          String newFullFileName=segmentDir + File.separator + newFileName;
          File newFile=new File(newFullFileName);
          newFile.createNewFile();
          String oldFullFileName=segmentDir + File.separator + lastSegment.getFileName();
          File oldFile=new File(oldFullFileName);
          oldFile.renameTo(newFile);
          lastSegment.setFileName(newFileName);
          lastSegment.setRandomAccessFile(RaftFileUtils.openFile(segmentDir,newFileName,"String_Node_Str"));
          lastSegment.setChannel(lastSegment.getRandomAccessFile().getChannel());
        }
      }
    }
    Segment newSegment;
    if (isNeedNewSegmentFile) {
      long newStartOffset=getLastEndOffset();
      String newSegmentFileName=String.format("String_Node_Str",newStartOffset);
      String newFullFileName=segmentDir + File.separator + newSegmentFileName;
      File newSegmentFile=new File(newFullFileName);
      if (!newSegmentFile.exists()) {
        newSegmentFile.createNewFile();
      }
      newSegment=new Segment(segmentDir,newSegmentFileName);
      startOffsetSegmentMap.put(newSegment.getStartOffset(),newSegment);
    }
 else {
      newSegment=startOffsetSegmentMap.lastEntry().getValue();
    }
    return newSegment.append(messageContent);
  }
 catch (  IOException ex) {
    throw new RuntimeException("String_Node_Str" + ex.getMessage());
  }
}

Fixed version (ground truth):
public boolean append(BrokerMessage.MessageContent.Builder message){
  boolean isNeedNewSegmentFile=false;
  int segmentSize=startOffsetSegmentMap.size();
  try {
    if (segmentSize == 0) {
      isNeedNewSegmentFile=true;
    }
 else {
      Segment lastSegment=startOffsetSegmentMap.lastEntry().getValue();
      if (!lastSegment.isCanWrite()) {
        isNeedNewSegmentFile=true;
      }
 else {
        int maxSegmentSize=GlobalConf.getInstance().getMaxSegmentSize();
        if (lastSegment.getFileSize() + message.build().getSerializedSize() > maxSegmentSize) {
          isNeedNewSegmentFile=true;
          lastSegment.close();
          lastSegment.setCanWrite(false);
          String newFileName=String.format("String_Node_Str",lastSegment.getStartOffset(),lastSegment.getEndOffset());
          String newFullFileName=segmentDir + File.separator + newFileName;
          File newFile=new File(newFullFileName);
          newFile.createNewFile();
          String oldFullFileName=segmentDir + File.separator + lastSegment.getFileName();
          File oldFile=new File(oldFullFileName);
          oldFile.renameTo(newFile);
          lastSegment.setFileName(newFileName);
          lastSegment.setRandomAccessFile(RaftFileUtils.openFile(segmentDir,newFileName,"String_Node_Str"));
          lastSegment.setChannel(lastSegment.getRandomAccessFile().getChannel());
        }
      }
    }
    Segment newSegment;
    if (isNeedNewSegmentFile) {
      long newStartOffset=getLastEndOffset();
      String newSegmentFileName=String.format("String_Node_Str",newStartOffset);
      String newFullFileName=segmentDir + File.separator + newSegmentFileName;
      File newSegmentFile=new File(newFullFileName);
      if (!newSegmentFile.exists()) {
        newSegmentFile.createNewFile();
      }
      newSegment=new Segment(segmentDir,newSegmentFileName);
      startOffsetSegmentMap.put(newSegment.getStartOffset(),newSegment);
    }
 else {
      newSegment=startOffsetSegmentMap.lastEntry().getValue();
    }
    return newSegment.append(message);
  }
 catch (  IOException ex) {
    throw new RuntimeException("String_Node_Str" + ex.getMessage());
  }
}