Program: 64015
Project: 64015
Buggy source:
@Override public void buildStack(Stack stack,String userData,Map<String,Object> setupProperties){
  AzureTemplate azureTemplate=(AzureTemplate)stack.getTemplate();
  Credential credential=(Credential)setupProperties.get(CREDENTIAL);
  String emailAsFolder=(String)setupProperties.get(EMAILASFOLDER);
  String filePath=AzureCertificateService.getUserJksFileName(credential,emailAsFolder);
  AzureClient azureClient=azureStackUtil.createAzureClient(credential,filePath);
  retryingStackUpdater.updateStackStatus(stack.getId(),Status.CREATE_IN_PROGRESS);
  String name=stack.getName().replaceAll("String_Node_Str","String_Node_Str") + String.valueOf(new Date().getTime());
  String commonName=((AzureCredential)credential).getCommonName();
  createAffinityGroup(azureClient,azureTemplate,commonName);
  createStorageAccount(azureClient,azureTemplate,commonName);
  createVirtualNetwork(azureClient,name,commonName);
  Set<Resource> resourceSet=new HashSet<>();
  resourceSet.add(new Resource(ResourceType.AFFINITY_GROUP,commonName,stack));
  resourceSet.add(new Resource(ResourceType.STORAGE,commonName,stack));
  resourceSet.add(new Resource(ResourceType.NETWORK,name,stack));
  for (int i=0; i < stack.getNodeCount(); i++) {
    try {
      String vmName=azureStackUtil.getVmName(name,i) + String.valueOf(new Date().getTime());
      createCloudService(azureClient,azureTemplate,vmName,commonName);
      createServiceCertificate(azureClient,azureTemplate,credential,vmName,emailAsFolder);
      String internalIp="String_Node_Str" + (i + VALID_IP_RANGE_START);
      createVirtualMachine(azureClient,azureTemplate,credential,name,vmName,commonName,userData,internalIp);
      resourceSet.add(new Resource(ResourceType.VIRTUAL_MACHINE,vmName,stack));
      resourceSet.add(new Resource(ResourceType.CLOUD_SERVICE,vmName,stack));
      resourceSet.add(new Resource(ResourceType.BLOB,vmName,stack));
    }
 catch (    FileNotFoundException e) {
      LOGGER.error(String.format("String_Node_Str",stack.getId()),e);
      reactor.notify(ReactorConfig.STACK_CREATE_FAILED_EVENT,Event.wrap(new StackCreationFailure(stack.getId(),"String_Node_Str")));
      return;
    }
catch (    CertificateException e) {
      LOGGER.error(String.format("String_Node_Str",stack.getId()),e);
      reactor.notify(ReactorConfig.STACK_CREATE_FAILED_EVENT,Event.wrap(new StackCreationFailure(stack.getId(),"String_Node_Str")));
      return;
    }
catch (    NoSuchAlgorithmException e) {
      LOGGER.error(String.format("String_Node_Str",stack.getId()),e);
      reactor.notify(ReactorConfig.STACK_CREATE_FAILED_EVENT,Event.wrap(new StackCreationFailure(stack.getId(),"String_Node_Str")));
      return;
    }
catch (    Exception e) {
      LOGGER.error(String.format("String_Node_Str",e.getMessage(),stack.getId()),e);
      reactor.notify(ReactorConfig.STACK_CREATE_FAILED_EVENT,Event.wrap(new StackCreationFailure(stack.getId(),"String_Node_Str" + e.getMessage())));
      return;
    }
  }
  LOGGER.info("String_Node_Str",ReactorConfig.PROVISION_COMPLETE_EVENT,stack.getId());
  reactor.notify(ReactorConfig.PROVISION_COMPLETE_EVENT,Event.wrap(new ProvisionComplete(CloudPlatform.AZURE,stack.getId(),resourceSet)));
}

Fixed version (ground truth):
@Override public void buildStack(Stack stack,String userData,Map<String,Object> setupProperties){
  AzureTemplate azureTemplate=(AzureTemplate)stack.getTemplate();
  Credential credential=(Credential)setupProperties.get(CREDENTIAL);
  String emailAsFolder=(String)setupProperties.get(EMAILASFOLDER);
  String filePath=AzureCertificateService.getUserJksFileName(credential,emailAsFolder);
  AzureClient azureClient=azureStackUtil.createAzureClient(credential,filePath);
  retryingStackUpdater.updateStackStatus(stack.getId(),Status.CREATE_IN_PROGRESS);
  String name=stack.getName().replaceAll("String_Node_Str","String_Node_Str") + String.valueOf(new Date().getTime());
  String commonName=((AzureCredential)credential).getCommonName();
  createAffinityGroup(stack,azureClient,azureTemplate,commonName);
  createStorageAccount(stack,azureClient,azureTemplate,commonName);
  createVirtualNetwork(azureClient,name,commonName);
  Set<Resource> resourceSet=new HashSet<>();
  resourceSet.add(new Resource(ResourceType.AFFINITY_GROUP,commonName,stack));
  resourceSet.add(new Resource(ResourceType.STORAGE,commonName,stack));
  resourceSet.add(new Resource(ResourceType.NETWORK,name,stack));
  for (int i=0; i < stack.getNodeCount(); i++) {
    try {
      String vmName=azureStackUtil.getVmName(name,i) + String.valueOf(new Date().getTime());
      createCloudService(azureClient,azureTemplate,vmName,commonName);
      createServiceCertificate(azureClient,azureTemplate,credential,vmName,emailAsFolder);
      String internalIp="String_Node_Str" + (i + VALID_IP_RANGE_START);
      createVirtualMachine(azureClient,azureTemplate,credential,name,vmName,commonName,userData,internalIp);
      resourceSet.add(new Resource(ResourceType.VIRTUAL_MACHINE,vmName,stack));
      resourceSet.add(new Resource(ResourceType.CLOUD_SERVICE,vmName,stack));
      resourceSet.add(new Resource(ResourceType.BLOB,vmName,stack));
    }
 catch (    FileNotFoundException e) {
      LOGGER.error(String.format("String_Node_Str",stack.getId()),e);
      reactor.notify(ReactorConfig.STACK_CREATE_FAILED_EVENT,Event.wrap(new StackCreationFailure(stack.getId(),"String_Node_Str")));
      return;
    }
catch (    CertificateException e) {
      LOGGER.error(String.format("String_Node_Str",stack.getId()),e);
      reactor.notify(ReactorConfig.STACK_CREATE_FAILED_EVENT,Event.wrap(new StackCreationFailure(stack.getId(),"String_Node_Str")));
      return;
    }
catch (    NoSuchAlgorithmException e) {
      LOGGER.error(String.format("String_Node_Str",stack.getId()),e);
      reactor.notify(ReactorConfig.STACK_CREATE_FAILED_EVENT,Event.wrap(new StackCreationFailure(stack.getId(),"String_Node_Str")));
      return;
    }
catch (    Exception e) {
      LOGGER.error(String.format("String_Node_Str",e.getMessage(),stack.getId()),e);
      reactor.notify(ReactorConfig.STACK_CREATE_FAILED_EVENT,Event.wrap(new StackCreationFailure(stack.getId(),"String_Node_Str" + e.getMessage())));
      return;
    }
  }
  LOGGER.info("String_Node_Str",ReactorConfig.PROVISION_COMPLETE_EVENT,stack.getId());
  reactor.notify(ReactorConfig.PROVISION_COMPLETE_EVENT,Event.wrap(new ProvisionComplete(CloudPlatform.AZURE,stack.getId(),resourceSet)));
}