Program: 55591
Project: 55591
Buggy source:
@Override public FileBaseStatistics getStatistics(BaseStatistics cachedStatistics){
  FileBaseStatistics stats=null;
  if (cachedStatistics != null && cachedStatistics instanceof FileBaseStatistics) {
    stats=(FileBaseStatistics)cachedStatistics;
  }
 else {
    stats=new FileBaseStatistics(-1,BaseStatistics.UNKNOWN,BaseStatistics.UNKNOWN);
  }
  try {
    final Path file=this.filePath;
    final URI uri=file.toUri();
    final FileSystem fs=FileSystem.get(uri);
    List<FileStatus> files=null;
{
      FileStatus status=fs.getFileStatus(file);
      if (status.isDir()) {
        FileStatus[] fss=fs.listStatus(file);
        files=new ArrayList<FileStatus>(fss.length);
        boolean unmodified=true;
        for (        FileStatus s : fss) {
          if (!s.isDir()) {
            files.add(s);
            if (s.getModificationTime() > stats.getLastModificationTime()) {
              stats.setFileModTime(s.getModificationTime());
              unmodified=false;
            }
          }
        }
        if (unmodified) {
          return stats;
        }
      }
 else {
        long modTime=status.getModificationTime();
        if (stats.getLastModificationTime() == modTime) {
          return stats;
        }
        stats.setFileModTime(modTime);
        files=new ArrayList<FileStatus>(1);
        files.add(status);
      }
    }
    stats.setAvgBytesPerRecord(-1.0f);
    stats.setFileSize(0);
    for (    FileStatus s : files) {
      stats.setFileSize(s.getLen());
    }
    if (stats.getTotalInputSize() <= 0) {
      stats.setFileSize(BaseStatistics.UNKNOWN);
      return stats;
    }
    final byte[] delimiter=getDelimiter();
    if (!((delimiter.length == 1 && delimiter[0] == '\n') || (delimiter.length == 2 && delimiter[0] == '\r' && delimiter[1] == '\n'))) {
      return stats;
    }
    int numSamples=Math.min(this.numLineSamples,(int)(stats.getTotalInputSize() / 1024));
    if (numSamples < 2) {
      numSamples=2;
    }
    long offset=0;
    long bytes=0;
    long stepSize=stats.getTotalInputSize() / numSamples;
    int fileNum=0;
    int samplesTaken=0;
    for (int sampleNum=0; sampleNum < numSamples && fileNum < files.size(); sampleNum++) {
      FileStatus currentFile=files.get(fileNum);
      FSDataInputStream inStream=null;
      try {
        inStream=fs.open(currentFile.getPath());
        LineReader lineReader=new LineReader(inStream,offset,currentFile.getLen() - offset,1024);
        byte[] line=lineReader.readLine();
        lineReader.close();
        if (line != null && line.length > 0) {
          samplesTaken++;
          bytes+=line.length + 1;
        }
      }
  finally {
        if (inStream != null) {
          try {
            inStream.close();
          }
 catch (          Throwable t) {
          }
        }
      }
      offset+=stepSize;
      while (fileNum < files.size() && offset >= (currentFile=files.get(fileNum)).getLen()) {
        offset-=currentFile.getLen();
        fileNum++;
      }
    }
    stats.setAvgBytesPerRecord(bytes / (float)samplesTaken);
  }
 catch (  IOException ioex) {
    if (LOG.isWarnEnabled())     LOG.warn("String_Node_Str" + filePath + "String_Node_Str"+ ioex.getMessage());
  }
catch (  Throwable t) {
    if (LOG.isErrorEnabled())     LOG.error("String_Node_Str" + filePath + "String_Node_Str"+ t.getMessage(),t);
  }
  return stats;
}

Fixed version (ground truth):
@Override public FileBaseStatistics getStatistics(BaseStatistics cachedStatistics){
  FileBaseStatistics stats=null;
  if (cachedStatistics != null && cachedStatistics instanceof FileBaseStatistics) {
    stats=(FileBaseStatistics)cachedStatistics;
  }
 else {
    stats=new FileBaseStatistics(-1,BaseStatistics.UNKNOWN,BaseStatistics.UNKNOWN);
  }
  try {
    final Path file=this.filePath;
    final URI uri=file.toUri();
    final FileSystem fs=FileSystem.get(uri);
    List<FileStatus> files=null;
{
      FileStatus status=fs.getFileStatus(file);
      if (status.isDir()) {
        FileStatus[] fss=fs.listStatus(file);
        files=new ArrayList<FileStatus>(fss.length);
        boolean unmodified=true;
        for (        FileStatus s : fss) {
          if (!s.isDir()) {
            files.add(s);
            if (s.getModificationTime() > stats.getLastModificationTime()) {
              stats.setFileModTime(s.getModificationTime());
              unmodified=false;
            }
          }
        }
        if (unmodified) {
          return stats;
        }
      }
 else {
        long modTime=status.getModificationTime();
        if (stats.getLastModificationTime() == modTime) {
          return stats;
        }
        stats.setFileModTime(modTime);
        files=new ArrayList<FileStatus>(1);
        files.add(status);
      }
    }
    stats.setAvgBytesPerRecord(-1.0f);
    stats.setFileSize(0);
    long totalInputSize=0;
    for (    FileStatus s : files) {
      totalInputSize+=s.getLen();
    }
    stats.setFileSize(totalInputSize);
    if (stats.getTotalInputSize() <= 0) {
      stats.setFileSize(BaseStatistics.UNKNOWN);
      return stats;
    }
    final byte[] delimiter=getDelimiter();
    if (!((delimiter.length == 1 && delimiter[0] == '\n') || (delimiter.length == 2 && delimiter[0] == '\r' && delimiter[1] == '\n'))) {
      return stats;
    }
    int numSamples=Math.min(this.numLineSamples,(int)(stats.getTotalInputSize() / 1024));
    if (numSamples < 2) {
      numSamples=2;
    }
    long offset=0;
    long bytes=0;
    long stepSize=stats.getTotalInputSize() / numSamples;
    int fileNum=0;
    int samplesTaken=0;
    for (int sampleNum=0; sampleNum < numSamples && fileNum < files.size(); sampleNum++) {
      FileStatus currentFile=files.get(fileNum);
      FSDataInputStream inStream=null;
      try {
        inStream=fs.open(currentFile.getPath());
        LineReader lineReader=new LineReader(inStream,offset,currentFile.getLen() - offset,1024);
        byte[] line=lineReader.readLine();
        lineReader.close();
        if (line != null && line.length > 0) {
          samplesTaken++;
          bytes+=line.length + 1;
        }
      }
  finally {
        if (inStream != null) {
          try {
            inStream.close();
          }
 catch (          Throwable t) {
          }
        }
      }
      offset+=stepSize;
      while (fileNum < files.size() && offset >= (currentFile=files.get(fileNum)).getLen()) {
        offset-=currentFile.getLen();
        fileNum++;
      }
    }
    stats.setAvgBytesPerRecord(bytes / (float)samplesTaken);
  }
 catch (  IOException ioex) {
    if (LOG.isWarnEnabled())     LOG.warn("String_Node_Str" + filePath + "String_Node_Str"+ ioex.getMessage());
  }
catch (  Throwable t) {
    if (LOG.isErrorEnabled())     LOG.error("String_Node_Str" + filePath + "String_Node_Str"+ t.getMessage(),t);
  }
  return stats;
}