Program: 5044
Project: 5044
Buggy source:
/** 
 * Loads the extensions and directories settings and rebuilds the file index.
 * @modifies this
 * @effects ensures that this contains exactly the files recursively givendirectories and all their recursive subdirectories.  If dir_names contains duplicate directories, the duplicates will be ignored.  If the directories list contains files, they will be ignored. Note that some files in this before the call will not be in this after the call, or they may have a different index. <b>WARNING: this is a potential security hazard.</b> WARNING: This call could run for a long time. Only threads that are prepared for that possibility should invoke it.  See the FileManager constructor for an example.
 */
public synchronized void loadSettings(){
  _size=0;
  _numFiles=0;
  _files=new ArrayList();
  _sharedDirectories=new HashSet();
  String dir_names=SettingsManager.instance().getDirectories();
  dir_names.trim();
  String[] names=HTTPUtil.stringSplit(dir_names,';');
  _extensions=HTTPUtil.stringSplit(SettingsManager.instance().getExtensions(),';');
  int size=names.length;
  File f;
  String p;
  String name;
  for (int i=0; i < size; i++) {
    name=names[i];
    f=new File(name);
    if (!f.isDirectory())     continue;
    try {
      p=f.getCanonicalPath();
    }
 catch (    Exception e) {
      continue;
    }
    _sharedDirectories.add(p);
  }
  int hashsize=_sharedDirectories.size();
  String[] dirs=new String[hashsize];
  int j=0;
  for (Iterator iter=_sharedDirectories.iterator(); iter.hasNext(); ) {
    dirs[j++]=(String)iter.next();
  }
  for (int i=0; i < hashsize; i++) {
    addDirectory(dirs[i]);
  }
}

Fixed version (ground truth):
/** 
 * Loads the extensions and directories settings and rebuilds the file index.
 * @modifies this
 * @effects ensures that this contains exactly the files recursively givendirectories and all their recursive subdirectories.  If dir_names contains duplicate directories, the duplicates will be ignored.  If the directories list contains files, they will be ignored. Note that some files in this before the call will not be in this after the call, or they may have a different index. <b>WARNING: this is a potential security hazard.</b> WARNING: This call could run for a long time. Only threads that are prepared for that possibility should invoke it.  See the FileManager constructor for an example.
 */
public synchronized void loadSettings(){
  _size=0;
  _numFiles=0;
  _files=new ArrayList();
  _index=new Trie(true);
  _sharedDirectories=new HashSet();
  String dir_names=SettingsManager.instance().getDirectories();
  dir_names.trim();
  String[] names=HTTPUtil.stringSplit(dir_names,';');
  _extensions=HTTPUtil.stringSplit(SettingsManager.instance().getExtensions(),';');
  int size=names.length;
  File f;
  String p;
  String name;
  for (int i=0; i < size; i++) {
    name=names[i];
    f=new File(name);
    if (!f.isDirectory())     continue;
    try {
      p=f.getCanonicalPath();
    }
 catch (    Exception e) {
      continue;
    }
    _sharedDirectories.add(p);
  }
  int hashsize=_sharedDirectories.size();
  String[] dirs=new String[hashsize];
  int j=0;
  for (Iterator iter=_sharedDirectories.iterator(); iter.hasNext(); ) {
    dirs[j++]=(String)iter.next();
  }
  for (int i=0; i < hashsize; i++) {
    addDirectory(dirs[i]);
  }
}