Program: 104153
Project: 104153
Buggy source:
/** 
 * Used to limit the files if any starting or ending date exist So only few files to be searched.
 * @param filelist Iterator
 * @param startDate Date
 * @param endDate Date
 * @return Iterator
 */
private Vector filterFilesByDate(Iterator filelist,Date startDate,Date endDate){
  if (startDate == null && endDate == null) {
    Vector result=new Vector();
    while (filelist.hasNext()) {
      result.add(filelist.next());
    }
    return result;
  }
  TreeSet files=new TreeSet();
  while (filelist.hasNext()) {
    String filename=(String)filelist.next();
    files.add(Long.parseLong(filename.substring(0,filename.length() - 4)));
  }
  TreeSet resultAsLong=new TreeSet();
  if (files.size() == 0) {
    Vector result=new Vector();
    Iterator iter=resultAsLong.iterator();
    while (iter.hasNext()) {
      Long item=(Long)iter.next();
      result.add(item.toString() + "String_Node_Str");
    }
    return result;
  }
  if (startDate == null) {
    Long endLong=Long.valueOf(endDate.getTime());
    files.add(endLong);
    resultAsLong.addAll(files.subSet(files.first(),endLong));
    resultAsLong.remove(endLong);
  }
 else   if (endDate == null) {
    Long startLong=Long.valueOf(startDate.getTime());
    if (files.size() > 0 && (startLong.longValue() < ((Long)files.first()).longValue())) {
      resultAsLong=files;
    }
 else {
      files.add(startLong);
      resultAsLong.addAll(files.subSet(startLong,files.last()));
      resultAsLong.add(files.last());
      resultAsLong.add(files.subSet(files.first(),startLong).last());
      resultAsLong.remove(startLong);
    }
  }
 else {
    Long startLong=Long.valueOf(startDate.getTime());
    Long endLong=Long.valueOf(endDate.getTime());
    files.add(startLong);
    files.add(endLong);
    resultAsLong.addAll(files.subSet(startLong,endLong));
    SortedSet theFirstToStart=files.subSet(files.first(),startLong);
    if (!theFirstToStart.isEmpty())     resultAsLong.add(theFirstToStart.last());
    resultAsLong.remove(startLong);
    resultAsLong.remove(endLong);
  }
  Vector result=new Vector();
  Iterator iter=resultAsLong.iterator();
  while (iter.hasNext()) {
    Long item=(Long)iter.next();
    result.add(item.toString() + "String_Node_Str");
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Used to limit the files if any starting or ending date exist So only few files to be searched.
 * @param filelist Iterator
 * @param startDate Date
 * @param endDate Date
 * @return Iterator
 */
private Vector<String> filterFilesByDate(Iterator<String> filelist,Date startDate,Date endDate){
  if (startDate == null && endDate == null) {
    Vector<String> result=new Vector<String>();
    while (filelist.hasNext()) {
      result.add(filelist.next());
    }
    return result;
  }
  TreeSet<Long> files=new TreeSet<Long>();
  while (filelist.hasNext()) {
    String filename=(String)filelist.next();
    files.add(Long.parseLong(filename.substring(0,filename.length() - 4)));
  }
  TreeSet<Long> resultAsLong=new TreeSet<Long>();
  if (files.size() == 0) {
    Vector<String> result=new Vector<String>();
    Iterator<Long> iter=resultAsLong.iterator();
    while (iter.hasNext()) {
      Long item=(Long)iter.next();
      result.add(item.toString() + "String_Node_Str");
    }
    return result;
  }
  if (startDate == null) {
    Long endLong=Long.valueOf(endDate.getTime());
    files.add(endLong);
    resultAsLong.addAll(files.subSet(files.first(),endLong));
    resultAsLong.remove(endLong);
  }
 else   if (endDate == null) {
    Long startLong=Long.valueOf(startDate.getTime());
    if (files.size() > 0 && (startLong.longValue() < ((Long)files.first()).longValue())) {
      resultAsLong=files;
    }
 else {
      files.add(startLong);
      resultAsLong.addAll(files.subSet(startLong,files.last()));
      resultAsLong.add(files.last());
      resultAsLong.add(files.subSet(files.first(),startLong).last());
      resultAsLong.remove(startLong);
    }
  }
 else {
    Long startLong=Long.valueOf(startDate.getTime());
    Long endLong=Long.valueOf(endDate.getTime());
    files.add(startLong);
    files.add(endLong);
    resultAsLong.addAll(files.subSet(startLong,endLong));
    SortedSet<Long> theFirstToStart=files.subSet(files.first(),startLong);
    if (!theFirstToStart.isEmpty())     resultAsLong.add(theFirstToStart.last());
    resultAsLong.remove(startLong);
    resultAsLong.remove(endLong);
  }
  Vector<String> result=new Vector<String>();
  Iterator<Long> iter=resultAsLong.iterator();
  while (iter.hasNext()) {
    Long item=iter.next();
    result.add(item.toString() + "String_Node_Str");
  }
  return result;
}