Program: 47097
Project: 47097
Buggy source:
@Override public void doRefreshChildren(){
  ArrayList<File> list=null;
  ArrayList<String> strings=null;
  int expectedOutput=0;
  if (sqls.length > 0) {
    String sql=sqls[0];
    expectedOutput=expectedOutputs[0];
    if (sql != null) {
      sql=transformSQL(sql);
      if (expectedOutput == FILES || expectedOutput == PLAYLISTS || expectedOutput == ISOS) {
        list=database.getFiles(sql);
      }
 else       if (expectedOutput == TEXTS) {
        strings=database.getStrings(sql);
      }
    }
  }
  ArrayList<File> addedFiles=new ArrayList<>();
  ArrayList<String> addedString=new ArrayList<>();
  ArrayList<DLNAResource> removedFiles=new ArrayList<>();
  ArrayList<DLNAResource> removedString=new ArrayList<>();
  int i=0;
  if (list != null) {
    for (    File file : list) {
      boolean present=false;
      for (      DLNAResource dlna : getChildren()) {
        if (i == 0 && (!(dlna instanceof VirtualFolder) || (dlna instanceof MediaLibraryFolder))) {
          removedFiles.add(dlna);
        }
        String name=dlna.getName();
        long lm=dlna.getLastModified();
        boolean videoTSHack=false;
        if (dlna instanceof DVDISOFile) {
          DVDISOFile dvdISOFile=(DVDISOFile)dlna;
          videoTSHack=dvdISOFile.getFilename().equals(file.getName());
        }
        if ((file.getName().equals(name) || videoTSHack) && file.lastModified() == lm) {
          removedFiles.remove(dlna);
          present=true;
        }
      }
      i++;
      if (!present) {
        addedFiles.add(file);
      }
    }
  }
  i=0;
  if (strings != null) {
    for (    String f : strings) {
      boolean present=false;
      for (      DLNAResource d : getChildren()) {
        if (i == 0 && (!(d instanceof VirtualFolder) || (d instanceof MediaLibraryFolder))) {
          removedString.add(d);
        }
        String name=d.getName();
        if (f.equals(name)) {
          removedString.remove(d);
          present=true;
        }
      }
      i++;
      if (!present) {
        addedString.add(f);
      }
    }
  }
  for (  DLNAResource f : removedFiles) {
    getChildren().remove(f);
  }
  for (  DLNAResource s : removedString) {
    getChildren().remove(s);
  }
  for (  File f : addedFiles) {
    if (expectedOutput == FILES) {
      addChild(new RealFile(f));
    }
 else     if (expectedOutput == PLAYLISTS) {
      addChild(new PlaylistFolder(f));
    }
 else     if (expectedOutput == ISOS) {
      addChild(new DVDISOFile(f));
    }
  }
  for (  String f : addedString) {
    if (expectedOutput == TEXTS) {
      String sqls2[]=new String[sqls.length - 1];
      int expectedOutputs2[]=new int[expectedOutputs.length - 1];
      System.arraycopy(sqls,1,sqls2,0,sqls2.length);
      System.arraycopy(expectedOutputs,1,expectedOutputs2,0,expectedOutputs2.length);
      addChild(new MediaLibraryFolder(f,sqls2,expectedOutputs2));
    }
  }
}

Fixed version (ground truth):
@Override public void doRefreshChildren(){
  ArrayList<File> list=null;
  ArrayList<String> strings=null;
  int expectedOutput=0;
  if (sqls.length > 0) {
    String sql=sqls[0];
    expectedOutput=expectedOutputs[0];
    if (sql != null) {
      sql=transformSQL(sql);
      if (expectedOutput == FILES || expectedOutput == PLAYLISTS || expectedOutput == ISOS) {
        list=database.getFiles(sql);
      }
 else       if (expectedOutput == TEXTS) {
        strings=database.getStrings(sql);
      }
    }
  }
  ArrayList<File> addedFiles=new ArrayList<>();
  ArrayList<String> addedString=new ArrayList<>();
  ArrayList<DLNAResource> removedFiles=new ArrayList<>();
  ArrayList<DLNAResource> removedString=new ArrayList<>();
  int i=0;
  if (list != null) {
    for (    File file : list) {
      boolean present=false;
      for (      DLNAResource dlna : getChildren()) {
        if (i == 0 && (!(dlna instanceof VirtualFolder) || (dlna instanceof MediaLibraryFolder))) {
          removedFiles.add(dlna);
        }
        String name=dlna.getName();
        long lm=dlna.getLastModified();
        boolean videoTSHack=false;
        if (dlna instanceof DVDISOFile) {
          DVDISOFile dvdISOFile=(DVDISOFile)dlna;
          videoTSHack=dvdISOFile.getFilename().equals(file.getName());
        }
        if ((file.getName().equals(name) || videoTSHack) && file.lastModified() == lm) {
          removedFiles.remove(dlna);
          present=true;
        }
      }
      i++;
      if (!present) {
        addedFiles.add(file);
      }
    }
  }
  i=0;
  if (strings != null) {
    for (    String f : strings) {
      boolean present=false;
      for (      DLNAResource d : getChildren()) {
        if (i == 0 && (!(d instanceof VirtualFolder) || (d instanceof MediaLibraryFolder))) {
          removedString.add(d);
        }
        String name=d.getName();
        if (f.equals(name)) {
          removedString.remove(d);
          present=true;
        }
      }
      i++;
      if (!present) {
        addedString.add(f);
      }
    }
  }
  for (  DLNAResource f : removedFiles) {
    getChildren().remove(f);
  }
  for (  DLNAResource s : removedString) {
    getChildren().remove(s);
  }
  for (  File f : addedFiles) {
    if (expectedOutput == FILES) {
      addChild(new RealFile(f));
    }
 else     if (expectedOutput == PLAYLISTS) {
      addChild(new PlaylistFolder(f));
    }
 else     if (expectedOutput == ISOS) {
      addChild(new DVDISOFile(f));
    }
  }
  for (  String f : addedString) {
    if (expectedOutput == TEXTS) {
      String sqls2[]=new String[sqls.length - 1];
      int expectedOutputs2[]=new int[expectedOutputs.length - 1];
      System.arraycopy(sqls,1,sqls2,0,sqls2.length);
      System.arraycopy(expectedOutputs,1,expectedOutputs2,0,expectedOutputs2.length);
      addChild(new MediaLibraryFolder(f,sqls2,expectedOutputs2));
    }
  }
  setUpdateId(this.getIntId());
}