Program: 10823
Project: 10823
Buggy source:
@Override public DeploymentDescriptor prepareForDeployment(final CloudFoundryServer server,final CloudFoundryApplicationModule appModule,final IProgressMonitor monitor){
  DeploymentDescriptor descriptor=null;
  CloudApplication existingApp=appModule.getApplication();
  if (existingApp != null) {
    descriptor=new DeploymentDescriptor();
    descriptor.applicationInfo=new ApplicationInfo(existingApp.getName());
    descriptor.deploymentInfo=new DeploymentInfo();
    descriptor.deploymentInfo.setUris(existingApp.getUris());
    descriptor.deploymentMode=ApplicationAction.START;
    DeploymentInfo lastDeploymentInfo=appModule.getLastDeploymentInfo();
    if (lastDeploymentInfo != null) {
      descriptor.deploymentInfo.setServices(lastDeploymentInfo.getServices());
    }
  }
 else {
    IModule module=appModule.getLocalModule();
    RepublishModule repModule=CloudFoundryPlugin.getModuleCache().getData(server.getServerOriginal()).untagForAutomaticRepublish(module);
    if (repModule != null) {
      descriptor=repModule.getDeploymentDescriptor();
    }
    if (!isValidDescriptor(descriptor,module)) {
      final DeploymentDescriptor[] depDescriptors=new DeploymentDescriptor[1];
      Display.getDefault().syncExec(new Runnable(){
        public void run(){
          IApplicationWizardDelegate providerDelegate=ApplicationWizardRegistry.getWizardProvider(appModule.getLocalModule());
          if (providerDelegate == null) {
            CloudFoundryPlugin.logError("String_Node_Str" + appModule.getApplicationId() + "String_Node_Str"+ server.getServer().getName()+ "String_Node_Str"+ appModule.getLocalModule().getModuleType().getId());
            return;
          }
          CloudFoundryApplicationWizard wizard=new CloudFoundryApplicationWizard(server,appModule,providerDelegate);
          WizardDialog dialog=new WizardDialog(PlatformUI.getWorkbench().getModalDialogShellProvider().getShell(),wizard);
          int status=dialog.open();
          if (status == Dialog.OK) {
            DeploymentDescriptor descriptorToUpdate=new DeploymentDescriptor();
            descriptorToUpdate.applicationInfo=wizard.getApplicationInfo();
            descriptorToUpdate.deploymentInfo=wizard.getDeploymentInfo();
            descriptorToUpdate.deploymentMode=wizard.getDeploymentMode();
            descriptorToUpdate.staging=wizard.getStaging();
            final List<CloudService> addedServices=wizard.getCreatedCloudServices();
            if (addedServices != null && !addedServices.isEmpty()) {
              IProgressMonitor subMonitor=new SubProgressMonitor(monitor,addedServices.size());
              try {
                server.getBehaviour().createService(addedServices.toArray(new CloudService[0]),subMonitor);
              }
 catch (              CoreException e) {
                CloudFoundryPlugin.logError(e);
              }
 finally {
                subMonitor.done();
              }
            }
            List<String> selectedServices=wizard.getSelectedServicesForBinding();
            descriptorToUpdate.deploymentInfo.setServices(selectedServices);
            depDescriptors[0]=descriptorToUpdate;
          }
        }
      }
);
      descriptor=depDescriptors[0];
    }
  }
  if (descriptor == null || descriptor.deploymentInfo == null) {
    throw new OperationCanceledException();
  }
  return descriptor;
}

Fixed version (ground truth):
@Override public DeploymentDescriptor prepareForDeployment(final CloudFoundryServer server,final CloudFoundryApplicationModule appModule,final IProgressMonitor monitor){
  DeploymentDescriptor descriptor=null;
  CloudApplication existingApp=appModule.getApplication();
  if (existingApp != null) {
    descriptor=new DeploymentDescriptor();
    descriptor.applicationInfo=new ApplicationInfo(existingApp.getName());
    descriptor.deploymentInfo=new DeploymentInfo();
    descriptor.deploymentInfo.setUris(existingApp.getUris());
    descriptor.deploymentMode=ApplicationAction.START;
    DeploymentInfo lastDeploymentInfo=appModule.getLastDeploymentInfo();
    if (lastDeploymentInfo != null) {
      descriptor.deploymentInfo.setServices(lastDeploymentInfo.getServices());
    }
  }
 else {
    IModule module=appModule.getLocalModule();
    RepublishModule repModule=CloudFoundryPlugin.getModuleCache().getData(server.getServerOriginal()).untagForAutomaticRepublish(module);
    if (repModule != null) {
      descriptor=repModule.getDeploymentDescriptor();
    }
    if (!isValidDescriptor(descriptor,module)) {
      final DeploymentDescriptor[] depDescriptors=new DeploymentDescriptor[1];
      Display.getDefault().syncExec(new Runnable(){
        public void run(){
          IApplicationWizardDelegate providerDelegate=ApplicationWizardRegistry.getWizardProvider(appModule.getLocalModule());
          if (providerDelegate == null) {
            CloudFoundryPlugin.logError("String_Node_Str" + appModule.getApplicationId() + "String_Node_Str"+ server.getServer().getName()+ "String_Node_Str"+ appModule.getLocalModule().getModuleType().getId());
            return;
          }
          CloudFoundryApplicationWizard wizard=new CloudFoundryApplicationWizard(server,appModule,providerDelegate);
          WizardDialog dialog=new WizardDialog(PlatformUI.getWorkbench().getModalDialogShellProvider().getShell(),wizard);
          int status=dialog.open();
          if (status == Dialog.OK) {
            DeploymentDescriptor descriptorToUpdate=new DeploymentDescriptor();
            descriptorToUpdate.applicationInfo=wizard.getApplicationInfo();
            descriptorToUpdate.deploymentInfo=wizard.getDeploymentInfo();
            descriptorToUpdate.deploymentMode=wizard.getDeploymentMode();
            descriptorToUpdate.staging=wizard.getStaging();
            final List<CloudService> addedServices=wizard.getCreatedCloudServices();
            if (addedServices != null && !addedServices.isEmpty()) {
              IProgressMonitor subMonitor=new SubProgressMonitor(monitor,addedServices.size());
              try {
                server.getBehaviour().createService(addedServices.toArray(new CloudService[0]),subMonitor);
              }
 catch (              CoreException e) {
                CloudFoundryPlugin.log(e);
              }
 finally {
                subMonitor.done();
              }
            }
            List<String> selectedServices=wizard.getSelectedServicesForBinding();
            descriptorToUpdate.deploymentInfo.setServices(selectedServices);
            depDescriptors[0]=descriptorToUpdate;
          }
        }
      }
);
      descriptor=depDescriptors[0];
    }
  }
  if (descriptor == null || descriptor.deploymentInfo == null) {
    throw new OperationCanceledException();
  }
  return descriptor;
}