Program: 10828
Project: 10828
Buggy source:
public void refreshUI(){
  resizeTableColumns();
  canUpdate=false;
  CloudFoundryApplicationModule appModule=getApplication();
  int state=appModule.getState();
  refreshPublishState();
  setCurrentStartDebugApplicationAction();
  instanceSpinner.setSelection(appModule.getInstanceCount());
  updateServerNameDisplay(appModule);
  refreshApplicationDeploymentButtons();
  mappedURIsLink.setEnabled(state == IServer.STATE_STARTED);
  CloudApplication cloudApplication=appModule.getApplication();
  List<CloudService> services=new ArrayList<CloudService>();
  instanceSpinner.setEnabled(cloudApplication != null);
  instancesViewer.getTable().setEnabled(cloudApplication != null);
  instancesViewer.setInput(null);
  if (provideServices) {
    List<String> serviceNames=null;
    DeploymentInfo deploymentInfo=appModule.getLastDeploymentInfo();
    if (deploymentInfo == null) {
      deploymentInfo=new DeploymentInfo();
      appModule.setLastDeploymentInfo(deploymentInfo);
      if (cloudApplication != null) {
        serviceNames=cloudApplication.getServices();
        deploymentInfo.setServices(serviceNames);
      }
    }
 else {
      serviceNames=deploymentInfo.getServices();
    }
    if (serviceNames == null) {
      serviceNames=Collections.emptyList();
    }
    List<CloudService> allServices=editorPage.getServices();
    if (allServices != null) {
      for (      CloudService service : allServices) {
        if (serviceNames.contains(service.getName())) {
          services.add(service);
        }
      }
    }
    servicesViewer.setInput(services.toArray(new CloudService[services.size()]));
  }
  memoryCombo.setEnabled(cloudApplication != null);
  if (cloudApplication != null) {
    int appMemory=appModule.getApplication().getMemory();
    memoryCombo.removeAll();
    boolean found=false;
    int[] applicationMemoryChoices=editorPage.getApplicationMemoryChoices();
    if (applicationMemoryChoices != null) {
      for (      int option : applicationMemoryChoices) {
        memoryCombo.add(option + "String_Node_Str");
        if (option == appMemory) {
          int index=memoryCombo.getItemCount() - 1;
          memoryCombo.select(index);
          found=true;
        }
      }
      if (!found && appMemory != 0) {
        memoryCombo.add(appMemory + "String_Node_Str",0);
        memoryCombo.select(0);
      }
      memoryCombo.setEnabled(true);
    }
  }
  List<String> currentURIs=null;
  if (cloudApplication != null) {
    currentURIs=cloudApplication.getUris();
    ApplicationStats applicationStats=appModule.getApplicationStats();
    InstancesInfo instancesInfo=appModule.getInstancesInfo();
    if (applicationStats != null) {
      List<InstanceStats> statss=applicationStats.getRecords();
      List<InstanceInfo> infos=instancesInfo != null ? instancesInfo.getInstances() : null;
      InstanceStatsAndInfo[] statsAndInfos=new InstanceStatsAndInfo[statss.size()];
      for (int i=0; i < statss.size(); i++) {
        InstanceStats stats=statss.get(i);
        InstanceInfo info=null;
        if (infos != null && infos.size() > i) {
          info=infos.get(i);
        }
        statsAndInfos[i]=new InstanceStatsAndInfo(stats,info);
      }
      instancesViewer.setInput(statsAndInfos);
    }
  }
  if (currentURIs == null && !isPublished) {
    currentURIs=appModule.getLastDeploymentInfo() != null ? appModule.getLastDeploymentInfo().getUris() : null;
  }
  if (currentURIs == null) {
    currentURIs=Collections.emptyList();
  }
  if (!currentURIs.equals(URIs)) {
    URIs=currentURIs;
    mappedURIsLink.setText(getURIsAsLinkText(URIs));
    generalSection.getParent().layout(true,true);
    editorPage.reflow();
  }
  if (provideServices) {
    servicesDropListener.setModule(appModule);
    servicesViewer.refresh(true);
  }
  instancesViewer.refresh(true);
  canUpdate=true;
  if (appModule.getErrorMessage() != null) {
    editorPage.setMessage(appModule.getErrorMessage(),IMessageProvider.ERROR);
  }
 else {
    editorPage.setMessage(null,IMessageProvider.ERROR);
  }
}

Fixed version (ground truth):
public void refreshUI(){
  resizeTableColumns();
  canUpdate=false;
  CloudFoundryApplicationModule appModule=getApplication();
  int state=appModule.getState();
  refreshPublishState();
  setCurrentStartDebugApplicationAction();
  instanceSpinner.setSelection(appModule.getInstanceCount());
  updateServerNameDisplay(appModule);
  refreshApplicationDeploymentButtons();
  mappedURIsLink.setEnabled(state == IServer.STATE_STARTED);
  CloudApplication cloudApplication=appModule.getApplication();
  List<CloudService> services=new ArrayList<CloudService>();
  instanceSpinner.setEnabled(cloudApplication != null);
  instancesViewer.getTable().setEnabled(cloudApplication != null);
  instancesViewer.setInput(null);
  if (provideServices) {
    List<String> serviceNames=null;
    DeploymentInfo deploymentInfo=appModule.getLastDeploymentInfo();
    if (deploymentInfo == null) {
      deploymentInfo=new DeploymentInfo();
      appModule.setLastDeploymentInfo(deploymentInfo);
      if (cloudApplication != null) {
        List<String> existingServices=cloudApplication.getServices();
        serviceNames=new ArrayList<String>();
        if (existingServices != null) {
          for (          String existingService : existingServices) {
            if (existingService != null) {
              serviceNames.add(existingService);
            }
          }
        }
        deploymentInfo.setServices(serviceNames);
      }
    }
 else {
      serviceNames=deploymentInfo.getServices();
    }
    if (serviceNames == null) {
      serviceNames=Collections.emptyList();
    }
    List<CloudService> allServices=editorPage.getServices();
    if (allServices != null) {
      for (      CloudService service : allServices) {
        if (serviceNames.contains(service.getName())) {
          services.add(service);
        }
      }
    }
    servicesViewer.setInput(services.toArray(new CloudService[services.size()]));
  }
  memoryCombo.setEnabled(cloudApplication != null);
  if (cloudApplication != null) {
    int appMemory=appModule.getApplication().getMemory();
    memoryCombo.removeAll();
    boolean found=false;
    int[] applicationMemoryChoices=editorPage.getApplicationMemoryChoices();
    if (applicationMemoryChoices != null) {
      for (      int option : applicationMemoryChoices) {
        memoryCombo.add(option + "String_Node_Str");
        if (option == appMemory) {
          int index=memoryCombo.getItemCount() - 1;
          memoryCombo.select(index);
          found=true;
        }
      }
      if (!found && appMemory != 0) {
        memoryCombo.add(appMemory + "String_Node_Str",0);
        memoryCombo.select(0);
      }
      memoryCombo.setEnabled(true);
    }
  }
  List<String> currentURIs=null;
  if (cloudApplication != null) {
    currentURIs=cloudApplication.getUris();
    ApplicationStats applicationStats=appModule.getApplicationStats();
    InstancesInfo instancesInfo=appModule.getInstancesInfo();
    if (applicationStats != null) {
      List<InstanceStats> statss=applicationStats.getRecords();
      List<InstanceInfo> infos=instancesInfo != null ? instancesInfo.getInstances() : null;
      InstanceStatsAndInfo[] statsAndInfos=new InstanceStatsAndInfo[statss.size()];
      for (int i=0; i < statss.size(); i++) {
        InstanceStats stats=statss.get(i);
        InstanceInfo info=null;
        if (infos != null && infos.size() > i) {
          info=infos.get(i);
        }
        statsAndInfos[i]=new InstanceStatsAndInfo(stats,info);
      }
      instancesViewer.setInput(statsAndInfos);
    }
  }
  if (currentURIs == null && !isPublished) {
    currentURIs=appModule.getLastDeploymentInfo() != null ? appModule.getLastDeploymentInfo().getUris() : null;
  }
  if (currentURIs == null) {
    currentURIs=Collections.emptyList();
  }
  if (!currentURIs.equals(URIs)) {
    URIs=currentURIs;
    mappedURIsLink.setText(getURIsAsLinkText(URIs));
    generalSection.getParent().layout(true,true);
    editorPage.reflow();
  }
  if (provideServices) {
    servicesDropListener.setModule(appModule);
    servicesViewer.refresh(true);
  }
  instancesViewer.refresh(true);
  canUpdate=true;
  if (appModule.getErrorMessage() != null) {
    editorPage.setMessage(appModule.getErrorMessage(),IMessageProvider.ERROR);
  }
 else {
    editorPage.setMessage(null,IMessageProvider.ERROR);
  }
}