Program: 189245
Project: 189245
Buggy source:
public void onSubmit(AjaxRequestTarget target,Form form){
  target.addComponent(done.setDefaultModel(new Model<String>(){
    public String getObject(){
      return "String_Node_Str";
    }
  }
));
  try {
    final UpdateDetails update=((DefaultManager)Manager.getInstance()).getAvailableUpdates().get(0);
    URL download=new URL(update.getFile());
    final long length=update.getLength();
    final URLConnection conn=download.openConnection();
    conn.connect();
    if (length > -1) {
      target.addComponent(this.setVisible(false));
      target.addComponent(run.setVisible(true));
      target.addComponent(bar.setVisible(true));
      bar.start(target);
    }
    final Thread restartThread=new Thread(){
      public void run(){
        try {
          sleep(1000);
        }
 catch (        InterruptedException e) {
        }
        try {
          UpdatingPanel.this.runtime.restart();
        }
 catch (        Exception e) {
          log.error("String_Node_Str",e);
        }
      }
    }
;
    new Thread(){
      public void run(){
        try {
          byte[] buffer=new byte[4096];
          long downloaded=0;
          InputStream in=conn.getInputStream();
          outFile=new File(org.headsupdev.agile.api.util.FileUtil.getTempDir(),new File(update.getFile()).getName());
          OutputStream out=new FileOutputStream(outFile);
          int chunk;
          while ((chunk=in.read(buffer)) > -1) {
            downloaded+=chunk;
            out.write(buffer,0,chunk);
            if (length > 0) {
              int prog=(int)(((double)downloaded / length) * 100);
              if (prog > 99) {
                prog=99;
              }
              progress=prog;
            }
          }
          in.close();
          out.close();
          outFile=new TarFile(new GZipFile(outFile).expand(true)).expand();
          File tmpDir=new File(outFile.getAbsolutePath() + "String_Node_Str");
          outFile.renameTo(tmpDir);
          File[] children=tmpDir.listFiles();
          outFile=new File(outFile.getParentFile(),outFile.getName());
          children[0].renameTo(outFile);
          tmpDir.delete();
          String version=new File(update.getFile()).getName();
          version=version.substring(0,version.indexOf("String_Node_Str"));
          Event event=new SystemEvent(Manager.getStorageInstance().getGlobalConfiguration().getProductName() + "String_Node_Str" + version,Manager.getStorageInstance().getGlobalConfiguration().getProductName() + "String_Node_Str" + version+ "String_Node_Str","String_Node_Str" + Manager.getStorageInstance().getGlobalConfiguration().getProductName() + "String_Node_Str"+ version+ "String_Node_Str"+ update.getDetails());
          Manager.getStorageInstance().addEvent(event);
          Manager.getInstance().fireEventAdded(event);
          Process chmodProcess=null;
          try {
            chmodProcess=Runtime.getRuntime().exec("String_Node_Str" + new File(outFile,"String_Node_Str").getAbsolutePath());
            chmodProcess.waitFor();
          }
 catch (          InterruptedException e) {
          }
 finally {
            if (chmodProcess != null) {
              IOUtil.close(chmodProcess.getOutputStream());
              IOUtil.close(chmodProcess.getErrorStream());
              IOUtil.close(chmodProcess.getInputStream());
              chmodProcess.destroy();
            }
          }
          updateProperties(new File(new File(outFile,"String_Node_Str"),"String_Node_Str"));
          File mainDir=new File("String_Node_Str");
          File backupDir=new File(mainDir,"String_Node_Str");
          if (backupDir.exists()) {
            for (            File child : backupDir.listFiles()) {
              FileUtil.delete(child);
            }
          }
 else {
            backupDir.mkdir();
          }
          for (          File child : mainDir.listFiles()) {
            if (child.equals(outFile)) {
              continue;
            }
            child.renameTo(new File(backupDir,child.getName()));
          }
          for (          File child : outFile.listFiles()) {
            child.renameTo(new File(mainDir,child.getName()));
          }
          outFile.delete();
          progress=100;
          restartThread.start();
        }
 catch (        IOException e) {
          log.error("String_Node_Str",e);
        }
      }
    }
.start();
  }
 catch (  IOException e) {
    log.error("String_Node_Str",e);
  }
}

Fixed version (ground truth):
public void onSubmit(AjaxRequestTarget target,Form form){
  target.addComponent(done.setDefaultModel(new Model<String>(){
    public String getObject(){
      return "String_Node_Str";
    }
  }
));
  try {
    final UpdateDetails update=((DefaultManager)Manager.getInstance()).getAvailableUpdates().get(0);
    URL download=new URL(update.getFile());
    final long length=update.getLength();
    URLConnection conn=download.openConnection();
    conn.connect();
    if (((HttpURLConnection)conn).getResponseCode() == 301 || ((HttpURLConnection)conn).getResponseCode() == 302) {
      String newLocation=conn.getHeaderField("String_Node_Str");
      download=new URL(newLocation);
      conn=download.openConnection();
      conn.connect();
    }
    if (length > -1) {
      target.addComponent(this.setVisible(false));
      target.addComponent(run.setVisible(true));
      target.addComponent(bar.setVisible(true));
      bar.start(target);
    }
    final Thread restartThread=new Thread(){
      public void run(){
        try {
          sleep(1000);
        }
 catch (        InterruptedException e) {
        }
        try {
          UpdatingPanel.this.runtime.restart();
        }
 catch (        Exception e) {
          log.error("String_Node_Str",e);
        }
      }
    }
;
    final URLConnection connection=conn;
    new Thread(){
      public void run(){
        try {
          byte[] buffer=new byte[4096];
          long downloaded=0;
          InputStream in=connection.getInputStream();
          outFile=new File(org.headsupdev.agile.api.util.FileUtil.getTempDir(),new File(update.getFile()).getName());
          OutputStream out=new FileOutputStream(outFile);
          int chunk;
          while ((chunk=in.read(buffer)) > -1) {
            downloaded+=chunk;
            out.write(buffer,0,chunk);
            if (length > 0) {
              int prog=(int)(((double)downloaded / length) * 100);
              if (prog > 99) {
                prog=99;
              }
              progress=prog;
            }
          }
          in.close();
          out.close();
          outFile=new TarFile(new GZipFile(outFile).expand(true)).expand();
          File tmpDir=new File(outFile.getAbsolutePath() + "String_Node_Str");
          outFile.renameTo(tmpDir);
          File[] children=tmpDir.listFiles();
          outFile=new File(outFile.getParentFile(),outFile.getName());
          children[0].renameTo(outFile);
          tmpDir.delete();
          String version=new File(update.getFile()).getName();
          version=version.substring(0,version.indexOf("String_Node_Str"));
          Event event=new SystemEvent(Manager.getStorageInstance().getGlobalConfiguration().getProductName() + "String_Node_Str" + version,Manager.getStorageInstance().getGlobalConfiguration().getProductName() + "String_Node_Str" + version+ "String_Node_Str","String_Node_Str" + Manager.getStorageInstance().getGlobalConfiguration().getProductName() + "String_Node_Str"+ version+ "String_Node_Str"+ update.getDetails());
          Manager.getStorageInstance().addEvent(event);
          Manager.getInstance().fireEventAdded(event);
          Process chmodProcess=null;
          try {
            chmodProcess=Runtime.getRuntime().exec("String_Node_Str" + new File(outFile,"String_Node_Str").getAbsolutePath());
            chmodProcess.waitFor();
          }
 catch (          InterruptedException e) {
          }
 finally {
            if (chmodProcess != null) {
              IOUtil.close(chmodProcess.getOutputStream());
              IOUtil.close(chmodProcess.getErrorStream());
              IOUtil.close(chmodProcess.getInputStream());
              chmodProcess.destroy();
            }
          }
          updateProperties(new File(new File(outFile,"String_Node_Str"),"String_Node_Str"));
          File mainDir=new File("String_Node_Str");
          File backupDir=new File(mainDir,"String_Node_Str");
          if (backupDir.exists()) {
            for (            File child : backupDir.listFiles()) {
              FileUtil.delete(child);
            }
          }
 else {
            backupDir.mkdir();
          }
          for (          File child : mainDir.listFiles()) {
            if (child.equals(outFile)) {
              continue;
            }
            child.renameTo(new File(backupDir,child.getName()));
          }
          for (          File child : outFile.listFiles()) {
            child.renameTo(new File(mainDir,child.getName()));
          }
          outFile.delete();
          progress=100;
          restartThread.start();
        }
 catch (        IOException e) {
          log.error("String_Node_Str",e);
        }
      }
    }
.start();
  }
 catch (  IOException e) {
    log.error("String_Node_Str",e);
  }
}