Program: 62927
Project: 62927
Buggy source:
/** 
 * @see com.alipay.rdf.file.interfaces.FileSplitter#getTailSlice(com.alipay.rdf.file.model.FileConfig)
 */
@Override public FileSlice getTailSlice(FileConfig fileConfig){
  String filePath=fileConfig.getFilePath();
  if (RdfFileLogUtil.common.isInfo()) {
    RdfFileLogUtil.common.info("String_Node_Str" + filePath);
  }
  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 (length == 0) {
    if (RdfFileLogUtil.common.isInfo()) {
      RdfFileLogUtil.common.info("String_Node_Str" + filePath + "String_Node_Str");
    }
    return new FileSlice(filePath,FileDataTypeEnum.TAIL,0,0);
  }
 else   if (RdfFileLogUtil.common.isDebug()) {
    RdfFileLogUtil.common.debug("String_Node_Str" + length);
  }
  FileMeta fileMeta=TemplateLoader.load(fileConfig.getTemplatePath(),fileConfig.getTemplateEncoding());
  if (!fileMeta.hasTail()) {
    throw new RdfFileException("String_Node_Str" + fileConfig.getTemplatePath() + "String_Node_Str",RdfErrorEnum.TAIL_NOT_DEFINED);
  }
  int tailRowsAffected=ProtocolLoader.getRowsAfftected(fileConfig,FileDataTypeEnum.TAIL);
  if (tailRowsAffected == 0) {
    if (RdfFileLogUtil.common.isInfo()) {
      RdfFileLogUtil.common.info("String_Node_Str" + tailRowsAffected);
    }
    return new FileSlice(filePath,FileDataTypeEnum.TAIL,length,length);
  }
 else   if (RdfFileLogUtil.common.isDebug()) {
    RdfFileLogUtil.common.debug("String_Node_Str" + tailRowsAffected);
  }
  RandomAccessFile raf=null;
  int tailLineCount=0;
  int count=0;
  long p=length - 1;
  boolean next=true;
  try {
    raf=new RandomAccessFile(file,"String_Node_Str");
    raf.seek(p);
    int last=raf.read();
    if (last != '\n' && last != '\r') {
      tailLineCount++;
      if (RdfFileLogUtil.common.isDebug()) {
        RdfFileLogUtil.common.debug("String_Node_Str");
      }
    }
    while (next) {
      count++;
      raf.seek(p--);
      int b=raf.read();
switch (b) {
case '\n':
case '\r':
        if (tailLineCount == tailRowsAffected) {
          count--;
          next=false;
          break;
        }
      if (p < 0) {
        next=false;
        if (RdfFileLogUtil.common.isDebug()) {
          RdfFileLogUtil.common.debug("String_Node_Str" + (b == '\r' ? "String_Node_Str" : "String_Node_Str"));
        }
        break;
      }
    raf.seek(p);
  int pre=raf.read();
if (pre != '\r' && pre != '\n') {
  tailLineCount++;
  if (RdfFileLogUtil.common.isDebug()) {
    RdfFileLogUtil.common.debug("String_Node_Str" + (b == '\r' ? "String_Node_Str" : "String_Node_Str"));
  }
}
break;
case -1:
count--;
next=false;
if (RdfFileLogUtil.common.isWarn()) {
RdfFileLogUtil.common.warn("String_Node_Str" + filePath + "String_Node_Str"+ count+ "String_Node_Str");
}
break;
default :
break;
}
if (p < 0) {
next=false;
if (RdfFileLogUtil.common.isDebug()) {
RdfFileLogUtil.common.debug("String_Node_Str");
}
}
}
}
 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);
}
}
}
}
long start=length - count;
if (RdfFileLogUtil.common.isInfo()) {
RdfFileLogUtil.common.info("String_Node_Str" + filePath + "String_Node_Str"+ count+ "String_Node_Str"+ start+ "String_Node_Str"+ length);
}
return new FileSlice(filePath,FileDataTypeEnum.TAIL,start,length);
}

Fixed version (ground truth):
/** 
 * @see com.alipay.rdf.file.interfaces.FileSplitter#getTailSlice(com.alipay.rdf.file.model.FileConfig)
 */
@Override public FileSlice getTailSlice(FileConfig fileConfig){
  String filePath=fileConfig.getFilePath();
  if (RdfFileLogUtil.common.isInfo()) {
    RdfFileLogUtil.common.info("String_Node_Str" + filePath);
  }
  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 (length == 0) {
    if (RdfFileLogUtil.common.isInfo()) {
      RdfFileLogUtil.common.info("String_Node_Str" + filePath + "String_Node_Str");
    }
    return new FileSlice(filePath,FileDataTypeEnum.TAIL,0,0);
  }
 else   if (RdfFileLogUtil.common.isDebug()) {
    RdfFileLogUtil.common.debug("String_Node_Str" + length);
  }
  if (fileConfig.getFileDataType() == FileDataTypeEnum.BODY || fileConfig.getFileDataType() == FileDataTypeEnum.HEAD) {
    return new FileSlice(fileConfig.getFilePath(),FileDataTypeEnum.TAIL,length,length);
  }
  FileMeta fileMeta=TemplateLoader.load(fileConfig.getTemplatePath(),fileConfig.getTemplateEncoding());
  if (!fileMeta.hasTail()) {
    throw new RdfFileException("String_Node_Str" + fileConfig.getTemplatePath() + "String_Node_Str",RdfErrorEnum.TAIL_NOT_DEFINED);
  }
  int tailRowsAffected=ProtocolLoader.getRowsAfftected(fileConfig,FileDataTypeEnum.TAIL);
  if (tailRowsAffected == 0) {
    if (RdfFileLogUtil.common.isInfo()) {
      RdfFileLogUtil.common.info("String_Node_Str" + tailRowsAffected);
    }
    return new FileSlice(filePath,FileDataTypeEnum.TAIL,length,length);
  }
 else   if (RdfFileLogUtil.common.isDebug()) {
    RdfFileLogUtil.common.debug("String_Node_Str" + tailRowsAffected);
  }
  RandomAccessFile raf=null;
  int tailLineCount=0;
  int count=0;
  long p=length - 1;
  boolean next=true;
  try {
    raf=new RandomAccessFile(file,"String_Node_Str");
    raf.seek(p);
    int last=raf.read();
    if (last != '\n' && last != '\r') {
      tailLineCount++;
      if (RdfFileLogUtil.common.isDebug()) {
        RdfFileLogUtil.common.debug("String_Node_Str");
      }
    }
    while (next) {
      count++;
      raf.seek(p--);
      int b=raf.read();
switch (b) {
case '\n':
case '\r':
        if (tailLineCount == tailRowsAffected) {
          count--;
          next=false;
          break;
        }
      if (p < 0) {
        next=false;
        if (RdfFileLogUtil.common.isDebug()) {
          RdfFileLogUtil.common.debug("String_Node_Str" + (b == '\r' ? "String_Node_Str" : "String_Node_Str"));
        }
        break;
      }
    raf.seek(p);
  int pre=raf.read();
if (pre != '\r' && pre != '\n') {
  tailLineCount++;
  if (RdfFileLogUtil.common.isDebug()) {
    RdfFileLogUtil.common.debug("String_Node_Str" + (b == '\r' ? "String_Node_Str" : "String_Node_Str"));
  }
}
break;
case -1:
count--;
next=false;
if (RdfFileLogUtil.common.isWarn()) {
RdfFileLogUtil.common.warn("String_Node_Str" + filePath + "String_Node_Str"+ count+ "String_Node_Str");
}
break;
default :
break;
}
if (p < 0) {
next=false;
if (RdfFileLogUtil.common.isDebug()) {
RdfFileLogUtil.common.debug("String_Node_Str");
}
}
}
}
 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);
}
}
}
}
long start=length - count;
if (RdfFileLogUtil.common.isInfo()) {
RdfFileLogUtil.common.info("String_Node_Str" + filePath + "String_Node_Str"+ count+ "String_Node_Str"+ start+ "String_Node_Str"+ length);
}
return new FileSlice(filePath,FileDataTypeEnum.TAIL,start,length);
}