Program: 64097
Project: 64097
Buggy source:
@Override public StackResult createStack(User user,Stack stack){
  AzureTemplate azureTemplate=(AzureTemplate)stack.getTemplate();
  String filePath=getUserJksFileName(user.emailAsFolder());
  File file=new File(filePath);
  AzureClient azureClient=new AzureClient(user.getSubscriptionId(),file.getAbsolutePath(),user.getJks());
  Map<String,String> props=new HashMap<>();
  props.put(NAME,azureTemplate.getName());
  props.put(LOCATION,AzureLocation.valueOf(azureTemplate.getLocation()).location());
  props.put(DESCRIPTION,azureTemplate.getDescription());
  HttpResponseDecorator affinityResponse=(HttpResponseDecorator)azureClient.createAffinityGroup(props);
  String requestId=(String)azureClient.getRequestId(affinityResponse);
  azureClient.waitUntilComplete(requestId);
  props=new HashMap<>();
  props.put(NAME,azureTemplate.getName());
  props.put(DESCRIPTION,azureTemplate.getDescription());
  props.put(AFFINITYGROUP,azureTemplate.getName());
  HttpResponseDecorator storageResponse=(HttpResponseDecorator)azureClient.createStorageAccount(props);
  requestId=(String)azureClient.getRequestId(storageResponse);
  azureClient.waitUntilComplete(requestId);
  props=new HashMap<>();
  props.put(NAME,azureTemplate.getName());
  props.put(AFFINITYGROUP,azureTemplate.getName());
  props.put(SUBNETNAME,azureTemplate.getSubnetAddressPrefix());
  props.put(ADDRESSPREFIX,azureTemplate.getSubnetAddressPrefix());
  props.put(SUBNETADDRESSPREFIX,azureTemplate.getSubnetAddressPrefix());
  HttpResponseDecorator virtualNetworkResponse=(HttpResponseDecorator)azureClient.createVirtualNetwork(props);
  requestId=(String)azureClient.getRequestId(virtualNetworkResponse);
  azureClient.waitUntilComplete(requestId);
  for (int i=0; i < stack.getClusterSize(); i++) {
    String vmName=String.format("String_Node_Str",azureTemplate.getName());
    props=new HashMap<>();
    props.put(NAME,vmName);
    props.put(DESCRIPTION,azureTemplate.getDescription());
    props.put(AFFINITYGROUP,azureTemplate.getName());
    HttpResponseDecorator cloudServiceResponse=(HttpResponseDecorator)azureClient.createCloudService(props);
    requestId=(String)azureClient.getRequestId(cloudServiceResponse);
    azureClient.waitUntilComplete(requestId);
    byte[] encoded=Base64.encodeBase64(vmName.getBytes());
    String label=new String(encoded);
    props=new HashMap<>();
    props.put(NAME,vmName);
    props.put(DEPLOYMENTSLOT,azureTemplate.getDeploymentSlot());
    props.put(LABEL,label);
    props.put(IMAGENAME,azureTemplate.getImageName());
    props.put(IMAGESTOREURI,String.format("String_Node_Str",azureTemplate.getName(),vmName));
    props.put(HOSTNAME,vmName);
    props.put(USERNAME,azureTemplate.getUserName());
    if (azureTemplate.getPassword() != null) {
      props.put(PASSWORD,azureTemplate.getPassword());
    }
 else {
      props.put(SSHPUBLICKEYFINGERPRINT,azureTemplate.getSshPublicKeyFingerprint());
      props.put(SSHPUBLICKEYPATH,azureTemplate.getSshPublicKeyPath());
    }
    props.put(SUBNETNAME,azureTemplate.getName());
    props.put(VIRTUALNETWORKNAME,azureTemplate.getName());
    props.put(VMTYPE,AzureVmType.valueOf(azureTemplate.getVmType()).vmType());
    HttpResponseDecorator virtualMachineResponse=(HttpResponseDecorator)azureClient.createVirtualMachine(props);
    requestId=(String)azureClient.getRequestId(virtualMachineResponse);
    azureClient.waitUntilComplete(requestId);
  }
  return new AzureStackResult(OK_STATUS);
}

Fixed version (ground truth):
@Override @Async public StackResult createStack(User user,Stack stack){
  AzureTemplate azureTemplate=(AzureTemplate)stack.getTemplate();
  String filePath=getUserJksFileName(user.emailAsFolder());
  File file=new File(filePath);
  AzureClient azureClient=new AzureClient(user.getSubscriptionId(),file.getAbsolutePath(),user.getJks());
  Map<String,String> props=new HashMap<>();
  props.put(NAME,azureTemplate.getName());
  props.put(LOCATION,AzureLocation.valueOf(azureTemplate.getLocation()).location());
  props.put(DESCRIPTION,azureTemplate.getDescription());
  HttpResponseDecorator affinityResponse=(HttpResponseDecorator)azureClient.createAffinityGroup(props);
  String requestId=(String)azureClient.getRequestId(affinityResponse);
  azureClient.waitUntilComplete(requestId);
  props=new HashMap<>();
  props.put(NAME,azureTemplate.getName());
  props.put(DESCRIPTION,azureTemplate.getDescription());
  props.put(AFFINITYGROUP,azureTemplate.getName());
  HttpResponseDecorator storageResponse=(HttpResponseDecorator)azureClient.createStorageAccount(props);
  requestId=(String)azureClient.getRequestId(storageResponse);
  azureClient.waitUntilComplete(requestId);
  props=new HashMap<>();
  props.put(NAME,azureTemplate.getName());
  props.put(AFFINITYGROUP,azureTemplate.getName());
  props.put(SUBNETNAME,azureTemplate.getSubnetAddressPrefix());
  props.put(ADDRESSPREFIX,azureTemplate.getAddressPrefix());
  props.put(SUBNETADDRESSPREFIX,azureTemplate.getSubnetAddressPrefix());
  HttpResponseDecorator virtualNetworkResponse=(HttpResponseDecorator)azureClient.createVirtualNetwork(props);
  requestId=(String)azureClient.getRequestId(virtualNetworkResponse);
  azureClient.waitUntilComplete(requestId);
  for (int i=0; i < stack.getClusterSize(); i++) {
    String vmName=String.format("String_Node_Str",azureTemplate.getName());
    props=new HashMap<>();
    props.put(NAME,vmName);
    props.put(DESCRIPTION,azureTemplate.getDescription());
    props.put(AFFINITYGROUP,azureTemplate.getName());
    HttpResponseDecorator cloudServiceResponse=(HttpResponseDecorator)azureClient.createCloudService(props);
    requestId=(String)azureClient.getRequestId(cloudServiceResponse);
    azureClient.waitUntilComplete(requestId);
    byte[] encoded=Base64.encodeBase64(vmName.getBytes());
    String label=new String(encoded);
    props=new HashMap<>();
    props.put(NAME,vmName);
    props.put(DEPLOYMENTSLOT,azureTemplate.getDeploymentSlot());
    props.put(LABEL,label);
    props.put(IMAGENAME,azureTemplate.getImageName());
    props.put(IMAGESTOREURI,String.format("String_Node_Str",azureTemplate.getName(),vmName));
    props.put(HOSTNAME,vmName);
    props.put(USERNAME,azureTemplate.getUserName());
    if (azureTemplate.getPassword() != null) {
      props.put(PASSWORD,azureTemplate.getPassword());
    }
 else {
      props.put(SSHPUBLICKEYFINGERPRINT,azureTemplate.getSshPublicKeyFingerprint());
      props.put(SSHPUBLICKEYPATH,azureTemplate.getSshPublicKeyPath());
    }
    props.put(SUBNETNAME,azureTemplate.getName());
    props.put(VIRTUALNETWORKNAME,azureTemplate.getName());
    props.put(VMTYPE,AzureVmType.valueOf(azureTemplate.getVmType()).vmType());
    HttpResponseDecorator virtualMachineResponse=(HttpResponseDecorator)azureClient.createVirtualMachine(props);
    requestId=(String)azureClient.getRequestId(virtualMachineResponse);
    azureClient.waitUntilComplete(requestId);
  }
  return new AzureStackResult(OK_STATUS);
}