Program: 189246
Project: 189246
Buggy source:
public UpdatingPanel(String id,HeadsUpRuntime runtime){
  super(id);
  this.runtime=runtime;
  final Model restartingModel=new Model<String>(){
    public String getObject(){
      return "String_Node_Str";
    }
  }
;
  final WebMarkupContainer run=new WebMarkupContainer("String_Node_Str");
  run.setOutputMarkupId(true);
  final Label done=new Label("String_Node_Str","String_Node_Str" + "String_Node_Str");
  done.setOutputMarkupId(true);
  final ProgressBar bar=new ProgressBar("String_Node_Str",new ProgressionModel(){
    protected Progression getProgression(){
      return new Progression(progress);
    }
  }
){
    protected void onFinished(    AjaxRequestTarget target){
      target.addComponent(run.setVisible(false));
      target.addComponent(this.setVisible(false));
      target.addComponent(done.setVisible(true));
      done.setDefaultModel(restartingModel);
    }
  }
;
  final Form updateForm=new Form("String_Node_Str");
  updateForm.add(new AjaxButton("String_Node_Str",updateForm){
    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);
      }
    }
  }
);
  updateForm.add(bar);
  bar.setVisible(false);
  updateForm.add(run);
  run.setVisible(false);
  updateForm.add(done);
  add(updateForm);
  setVisible(((DefaultManager)Manager.getInstance()).getAvailableUpdates().size() > 0 && Manager.getSecurityInstance().userHasPermission(((HeadsUpSession)Session.get()).getUser(),new AdminPermission(),null));
}

Fixed version (ground truth):
public UpdatingPanel(String id,HeadsUpRuntime runtime){
  super(id);
  this.runtime=runtime;
  final Model restartingModel=new Model<String>(){
    public String getObject(){
      return "String_Node_Str";
    }
  }
;
  final WebMarkupContainer run=new WebMarkupContainer("String_Node_Str");
  run.setOutputMarkupId(true);
  final Label done=new Label("String_Node_Str","String_Node_Str" + "String_Node_Str");
  done.setOutputMarkupId(true);
  final ProgressBar bar=new ProgressBar("String_Node_Str",new ProgressionModel(){
    protected Progression getProgression(){
      return new Progression(progress);
    }
  }
){
    protected void onFinished(    AjaxRequestTarget target){
      target.addComponent(run.setVisible(false));
      target.addComponent(this.setVisible(false));
      target.addComponent(done.setVisible(true));
      done.setDefaultModel(restartingModel);
    }
  }
;
  final Form updateForm=new Form("String_Node_Str");
  updateForm.add(new AjaxButton("String_Node_Str",updateForm){
    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);
      }
    }
  }
);
  updateForm.add(bar);
  bar.setVisible(false);
  updateForm.add(run);
  run.setVisible(false);
  updateForm.add(done);
  add(updateForm);
  setVisible(((DefaultManager)Manager.getInstance()).getAvailableUpdates().size() > 0 && Manager.getSecurityInstance().userHasPermission(((HeadsUpSession)Session.get()).getUser(),new AdminPermission(),null));
}