Program: 62928
Project: 62928
Buggy source:
/** 
 * @see com.alipay.rdf.file.interfaces.FileSplitter#getHeadSlice(com.alipay.rdf.file.model.FileConfig)
 */
@Override public FileSlice getHeadSlice(FileConfig fileConfig){
  String filePath=fileConfig.getFilePath();
  RdfFileLogUtil.common.info("String_Node_Str" + filePath + "String_Node_Str");
  File file=new File(filePath);
  if (!file.exists()) {
    throw new RdfFileException("String_Node_Str" + filePath + "String_Node_Str",RdfErrorEnum.NOT_EXSIT);
  }
  long length=file.length();
  if (0 == length) {
    RdfFileLogUtil.common.warn("String_Node_Str" + filePath + "String_Node_Str");
    return new FileSlice(filePath,FileDataTypeEnum.HEAD,0,0);
  }
 else {
    RdfFileLogUtil.common.debug("String_Node_Str" + length);
  }
  FileMeta fileMeta=TemplateLoader.load(fileConfig.getTemplatePath(),fileConfig.getTemplateEncoding());
  if (!fileMeta.hasHead()) {
    throw new RdfFileException("String_Node_Str" + fileConfig.getTemplatePath() + "String_Node_Str",RdfErrorEnum.HEAD_NOT_DEFINED);
  }
  int headRowsAffected=ProtocolLoader.getRowsAfftected(fileConfig,FileDataTypeEnum.HEAD);
  if (headRowsAffected == 0) {
    RdfFileLogUtil.common.info("String_Node_Str" + headRowsAffected);
    return new FileSlice(filePath,FileDataTypeEnum.HEAD,0,0);
  }
 else {
    RdfFileLogUtil.common.debug("String_Node_Str" + headRowsAffected);
  }
  RandomAccessFile raf=null;
  int headLineCount=0;
  int count=0;
  boolean next=true;
  try {
    raf=new RandomAccessFile(file,"String_Node_Str");
    raf.seek(0);
    while (next) {
      count++;
      int b=raf.read();
switch (b) {
case '\n':
case '\r':
        long cur=raf.getFilePointer();
      int pre=raf.read();
    if (pre == -1 || pre != '\n') {
      headLineCount++;
      if (RdfFileLogUtil.common.isDebug()) {
        RdfFileLogUtil.common.debug("String_Node_Str" + (b == '\r' ? "String_Node_Str" : "String_Node_Str"));
      }
    }
  if (headLineCount == headRowsAffected) {
    next=false;
    break;
  }
raf.seek(cur);
break;
case -1:
count--;
next=false;
if (RdfFileLogUtil.common.isWarn()) {
RdfFileLogUtil.common.warn("String_Node_Str" + count + "String_Node_Str");
}
break;
default :
break;
}
}
}
 catch (FileNotFoundException e) {
throw new RdfFileException("String_Node_Str" + file.getAbsolutePath() + "String_Node_Str",e,RdfErrorEnum.NOT_EXSIT);
}
catch (IOException e) {
throw new RdfFileException("String_Node_Str",e,RdfErrorEnum.NOT_EXSIT);
}
 finally {
if (null != raf) {
try {
raf.close();
}
 catch (IOException e) {
if (RdfFileLogUtil.common.isWarn()) {
RdfFileLogUtil.common.warn("String_Node_Str",e);
}
}
}
}
if (RdfFileLogUtil.common.isInfo()) {
RdfFileLogUtil.common.info("String_Node_Str" + filePath + "String_Node_Str"+ count);
}
return new FileSlice(filePath,FileDataTypeEnum.HEAD,0,count);
}

Fixed version (ground truth):
/** 
 * @see com.alipay.rdf.file.interfaces.FileSplitter#getHeadSlice(com.alipay.rdf.file.model.FileConfig)
 */
@Override public FileSlice getHeadSlice(FileConfig fileConfig){
  String filePath=fileConfig.getFilePath();
  RdfFileLogUtil.common.info("String_Node_Str" + filePath + "String_Node_Str");
  File file=new File(filePath);
  if (!file.exists()) {
    throw new RdfFileException("String_Node_Str" + filePath + "String_Node_Str",RdfErrorEnum.NOT_EXSIT);
  }
  long length=file.length();
  if (0 == length) {
    RdfFileLogUtil.common.warn("String_Node_Str" + filePath + "String_Node_Str");
    return new FileSlice(filePath,FileDataTypeEnum.HEAD,0,0);
  }
 else {
    RdfFileLogUtil.common.debug("String_Node_Str" + length);
  }
  if (fileConfig.getFileDataType() == FileDataTypeEnum.BODY || fileConfig.getFileDataType() == FileDataTypeEnum.TAIL) {
    return new FileSlice(fileConfig.getFilePath(),FileDataTypeEnum.HEAD,0,0);
  }
  FileMeta fileMeta=TemplateLoader.load(fileConfig.getTemplatePath(),fileConfig.getTemplateEncoding());
  if (!fileMeta.hasHead()) {
    throw new RdfFileException("String_Node_Str" + fileConfig.getTemplatePath() + "String_Node_Str",RdfErrorEnum.HEAD_NOT_DEFINED);
  }
  int headRowsAffected=ProtocolLoader.getRowsAfftected(fileConfig,FileDataTypeEnum.HEAD);
  if (headRowsAffected == 0) {
    RdfFileLogUtil.common.info("String_Node_Str" + headRowsAffected);
    return new FileSlice(filePath,FileDataTypeEnum.HEAD,0,0);
  }
 else {
    RdfFileLogUtil.common.debug("String_Node_Str" + headRowsAffected);
  }
  RandomAccessFile raf=null;
  int headLineCount=0;
  int count=0;
  boolean next=true;
  try {
    raf=new RandomAccessFile(file,"String_Node_Str");
    raf.seek(0);
    while (next) {
      count++;
      int b=raf.read();
switch (b) {
case '\n':
case '\r':
        long cur=raf.getFilePointer();
      int pre=raf.read();
    if (pre == -1 || pre != '\n') {
      headLineCount++;
      if (RdfFileLogUtil.common.isDebug()) {
        RdfFileLogUtil.common.debug("String_Node_Str" + (b == '\r' ? "String_Node_Str" : "String_Node_Str"));
      }
    }
  if (headLineCount == headRowsAffected) {
    next=false;
    break;
  }
raf.seek(cur);
break;
case -1:
count--;
next=false;
if (RdfFileLogUtil.common.isWarn()) {
RdfFileLogUtil.common.warn("String_Node_Str" + count + "String_Node_Str");
}
break;
default :
break;
}
}
}
 catch (FileNotFoundException e) {
throw new RdfFileException("String_Node_Str" + file.getAbsolutePath() + "String_Node_Str",e,RdfErrorEnum.NOT_EXSIT);
}
catch (IOException e) {
throw new RdfFileException("String_Node_Str",e,RdfErrorEnum.NOT_EXSIT);
}
 finally {
if (null != raf) {
try {
raf.close();
}
 catch (IOException e) {
if (RdfFileLogUtil.common.isWarn()) {
RdfFileLogUtil.common.warn("String_Node_Str",e);
}
}
}
}
if (RdfFileLogUtil.common.isInfo()) {
RdfFileLogUtil.common.info("String_Node_Str" + filePath + "String_Node_Str"+ count);
}
return new FileSlice(filePath,FileDataTypeEnum.HEAD,0,count);
}