Program: 21158
Project: 21158
Buggy source:
public JDUpdater() throws Exception {
  String wd=new File("String_Node_Str").getAbsolutePath();
  JFileChooser fc=new JFileChooser();
  System.out.print("String_Node_Str");
  fc.setApproveButtonText("String_Node_Str");
  fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
  fc.setSelectedFile((File)CONFIG.getProperty("String_Node_Str",new File(new File(wd).getParentFile(),"String_Node_Str")));
  if (fc.showOpenDialog(null) != JFileChooser.APPROVE_OPTION) {
    logger.severe("String_Node_Str");
    return;
  }
  SKIP_UPLOAD=(JOptionPane.showConfirmDialog(null,"String_Node_Str") == JOptionPane.OK_OPTION);
  workingdir=fc.getSelectedFile();
  if (workingdir == null) {
    logger.severe("String_Node_Str");
    return;
  }
  CONFIG.setProperty("String_Node_Str",workingdir);
  System.out.print("String_Node_Str" + workingdir.getAbsolutePath() + "String_Node_Str");
  if (!new File("String_Node_Str").getAbsolutePath().equals(workingdir.getAbsolutePath())) {
    System.out.print("String_Node_Str");
    System.err.println("String_Node_Str" + workingdir + "String_Node_Str"+ new File("String_Node_Str").getAbsolutePath());
    return;
  }
  fc=new JFileChooser();
  System.out.print("String_Node_Str");
  fc.setApproveButtonText("String_Node_Str");
  fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
  fc.setSelectedFile((File)CONFIG.getProperty("String_Node_Str",new File(new File(wd).getParentFile(),"String_Node_Str")));
  if (fc.showOpenDialog(null) != JFileChooser.APPROVE_OPTION) {
    logger.severe("String_Node_Str");
    return;
  }
  dir=fc.getSelectedFile();
  if (dir == null) {
    logger.severe("String_Node_Str");
    return;
  }
  CONFIG.setProperty("String_Node_Str",dir);
  CONFIG.save();
  System.out.print("String_Node_Str" + dir.getAbsolutePath() + "String_Node_Str");
  webRoot="String_Node_Str";
  System.out.println("String_Node_Str" + webRoot);
  System.out.println("String_Node_Str");
  WebUpdater updater=new WebUpdater();
  updater.useUpdatePrefixFromServer(false);
  updater.setOSFilter(false);
  WebUpdater.setJDDirectory(workingdir);
  updater.ignorePlugins(false);
  Vector<Vector<String>> files=null;
  try {
    files=updater.getAvailableFiles();
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  ArrayList<File> localfiles=getLocalFileList(workingdir);
  HashMap<String,String> webupdaterfiles=new HashMap<String,String>();
  if (files == null)   files=new Vector<Vector<String>>();
  for (int i=0; i < files.size(); i++) {
    String path=files.get(i).get(0).split("String_Node_Str")[0];
    File f=new File(this.workingdir,path);
    webupdaterfiles.put(f.getAbsolutePath(),files.get(i).get(1));
  }
  System.out.println("String_Node_Str");
  ArrayList<String> hashlist=new ArrayList<String>();
  for (  File f : localfiles) {
    if (f.getName().endsWith("String_Node_Str")) {
      hashlist.add(JDHash.getMD5(f));
    }
    if (!webupdaterfiles.containsKey(f.getAbsolutePath())) {
      if (!f.isDirectory()) {
        int answer=JOptionPane.showConfirmDialog(null,"String_Node_Str" + f.getAbsolutePath() + "String_Node_Str");
        if (answer == JOptionPane.CANCEL_OPTION)         break;
        if (answer == JOptionPane.OK_OPTION) {
          if (!f.delete()) {
            logger.severe("String_Node_Str" + f + "String_Node_Str");
            return;
          }
        }
      }
    }
  }
  System.out.println(hashlist);
  System.out.println("String_Node_Str");
  if (files != null) {
    updater.filterAvailableUpdates(files);
    updater.updateFiles(files);
  }
  System.out.println("String_Node_Str");
  while (true) {
    fc=new JFileChooser();
    System.out.println("String_Node_Str");
    fc.setApproveButtonText("String_Node_Str");
    fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    fc.setSelectedFile(this.workingdir);
    if (fc.showOpenDialog(null) != JFileChooser.APPROVE_OPTION) {
      break;
    }
    File[] filesToRemove=fc.getSelectedFiles();
    if (filesToRemove == null) {
      break;
    }
    for (    File f : filesToRemove) {
      if (JOptionPane.showConfirmDialog(null,"String_Node_Str" + f.getAbsolutePath() + "String_Node_Str") == JOptionPane.OK_OPTION) {
        if (!JDUtilities.removeDirectoryOrFile(f)) {
          logger.severe("String_Node_Str" + f + "String_Node_Str");
        }
 else {
          System.out.println("String_Node_Str" + f);
        }
        return;
      }
    }
  }
  if (!update()) {
    logger.severe("String_Node_Str");
    return;
  }
  filelist=new ArrayList<File>();
  scanDir(new File(wd));
  logger.info("String_Node_Str");
  StringBuilder sb=new StringBuilder();
  for (  File file : filelist) {
    String sub=file.toString().substring(new File(wd).toString().length() + 1).replaceAll("String_Node_Str","String_Node_Str");
    if (sub.startsWith("String_Node_Str"))     continue;
    sb.append("String_Node_Str" + sub + "String_Node_Str"+ webRoot+ sub+ "String_Node_Str"+ JDHash.getMD5(file)+ "String_Node_Str");
  }
  logger.info(sb + "String_Node_Str");
  upload(sb + "String_Node_Str");
}

Fixed version (ground truth):
public JDUpdater() throws Exception {
  String wd=new File("String_Node_Str").getAbsolutePath();
  JFileChooser fc=new JFileChooser();
  System.out.print("String_Node_Str");
  fc.setApproveButtonText("String_Node_Str");
  fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
  fc.setSelectedFile((File)CONFIG.getProperty("String_Node_Str",new File(new File(wd).getParentFile(),"String_Node_Str")));
  Thread.sleep(3000);
  if (fc.showOpenDialog(null) != JFileChooser.APPROVE_OPTION) {
    logger.severe("String_Node_Str");
    return;
  }
  Thread.sleep(3000);
  SKIP_UPLOAD=(JOptionPane.showConfirmDialog(null,"String_Node_Str") == JOptionPane.OK_OPTION);
  workingdir=fc.getSelectedFile();
  if (workingdir == null) {
    logger.severe("String_Node_Str");
    return;
  }
  CONFIG.setProperty("String_Node_Str",workingdir);
  System.out.print("String_Node_Str" + workingdir.getAbsolutePath() + "String_Node_Str");
  if (!new File("String_Node_Str").getAbsolutePath().equals(workingdir.getAbsolutePath())) {
    System.out.print("String_Node_Str");
    System.err.println("String_Node_Str" + workingdir + "String_Node_Str"+ new File("String_Node_Str").getAbsolutePath());
    return;
  }
  fc=new JFileChooser();
  System.out.print("String_Node_Str");
  fc.setApproveButtonText("String_Node_Str");
  fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
  fc.setSelectedFile((File)CONFIG.getProperty("String_Node_Str",new File(new File(wd).getParentFile(),"String_Node_Str")));
  Thread.sleep(3000);
  if (fc.showOpenDialog(null) != JFileChooser.APPROVE_OPTION) {
    logger.severe("String_Node_Str");
    return;
  }
  dir=fc.getSelectedFile();
  if (dir == null) {
    logger.severe("String_Node_Str");
    return;
  }
  CONFIG.setProperty("String_Node_Str",dir);
  CONFIG.save();
  System.out.print("String_Node_Str" + dir.getAbsolutePath() + "String_Node_Str");
  webRoot="String_Node_Str";
  System.out.println("String_Node_Str" + webRoot);
  System.out.println("String_Node_Str");
  WebUpdater updater=new WebUpdater();
  updater.useUpdatePrefixFromServer(false);
  updater.setOSFilter(false);
  WebUpdater.setJDDirectory(workingdir);
  updater.ignorePlugins(false);
  Vector<Vector<String>> files=null;
  try {
    files=updater.getAvailableFiles();
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  ArrayList<File> localfiles=getLocalFileList(workingdir);
  HashMap<String,String> webupdaterfiles=new HashMap<String,String>();
  if (files == null)   files=new Vector<Vector<String>>();
  for (int i=0; i < files.size(); i++) {
    String path=files.get(i).get(0).split("String_Node_Str")[0];
    File f=new File(this.workingdir,path);
    webupdaterfiles.put(f.getAbsolutePath(),files.get(i).get(1));
  }
  System.out.println("String_Node_Str");
  ArrayList<String> hashlist=new ArrayList<String>();
  for (  File f : localfiles) {
    if (f.getName().endsWith("String_Node_Str")) {
      hashlist.add(JDHash.getMD5(f));
    }
    if (!webupdaterfiles.containsKey(f.getAbsolutePath())) {
      if (!f.isDirectory()) {
        Thread.sleep(3000);
        int answer=JOptionPane.showConfirmDialog(null,"String_Node_Str" + f.getAbsolutePath() + "String_Node_Str");
        if (answer == JOptionPane.CANCEL_OPTION)         break;
        if (answer == JOptionPane.OK_OPTION) {
          if (!f.delete()) {
            logger.severe("String_Node_Str" + f + "String_Node_Str");
            return;
          }
        }
      }
    }
  }
  System.out.println(hashlist);
  System.out.println("String_Node_Str");
  if (files != null) {
    updater.filterAvailableUpdates(files);
    updater.updateFiles(files);
  }
  System.out.println("String_Node_Str");
  while (true) {
    fc=new JFileChooser();
    System.out.println("String_Node_Str");
    fc.setApproveButtonText("String_Node_Str");
    fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    fc.setSelectedFile(this.workingdir);
    Thread.sleep(3000);
    if (fc.showOpenDialog(null) != JFileChooser.APPROVE_OPTION) {
      break;
    }
    File[] filesToRemove=fc.getSelectedFiles();
    if (filesToRemove == null) {
      break;
    }
    for (    File f : filesToRemove) {
      Thread.sleep(3000);
      if (JOptionPane.showConfirmDialog(null,"String_Node_Str" + f.getAbsolutePath() + "String_Node_Str") == JOptionPane.OK_OPTION) {
        if (!JDUtilities.removeDirectoryOrFile(f)) {
          logger.severe("String_Node_Str" + f + "String_Node_Str");
        }
 else {
          System.out.println("String_Node_Str" + f);
        }
        return;
      }
    }
  }
  if (!update()) {
    logger.severe("String_Node_Str");
    return;
  }
  filelist=new ArrayList<File>();
  scanDir(new File(wd));
  logger.info("String_Node_Str");
  StringBuilder sb=new StringBuilder();
  for (  File file : filelist) {
    String sub=file.toString().substring(new File(wd).toString().length() + 1).replaceAll("String_Node_Str","String_Node_Str");
    if (sub.startsWith("String_Node_Str"))     continue;
    sb.append("String_Node_Str" + sub + "String_Node_Str"+ webRoot+ sub+ "String_Node_Str"+ JDHash.getMD5(file)+ "String_Node_Str");
  }
  logger.info(sb + "String_Node_Str");
  upload(sb + "String_Node_Str");
}