Program: 64071
Project: 64071
Buggy source:
@Override public void setupProvisioning(Stack stack){
  LOGGER.info("String_Node_Str",ReactorConfig.PROVISION_SETUP_COMPLETE_EVENT,stack.getId());
  Credential credential=stack.getCredential();
  String emailAsFolder=stack.getUser().emailAsFolder();
  String filePath=AzureCertificateService.getUserJksFileName(credential,emailAsFolder);
  File file=new File(filePath);
  AzureClient azureClient=new AzureClient(((AzureCredential)credential).getSubscriptionId(),file.getAbsolutePath(),((AzureCredential)credential).getJks());
  if (!azureClient.isImageAvailable(IMAGE_NAME)) {
    String baseImageUri="String_Node_Str";
    try {
      Map<String,String> params=new HashMap<>();
      params.put(AzureStackUtil.NAME,VM_COMMON_NAME);
      params.put(DESCRIPTION,VM_COMMON_NAME);
      params.put(LOCATION,"String_Node_Str");
      azureClient.createAffinityGroup(params);
    }
 catch (    Exception ex) {
      LOGGER.info("String_Node_Str");
    }
    String storageName=String.format("String_Node_Str",VM_COMMON_NAME,stack.getId());
    try {
      Map<String,String> params=new HashMap<>();
      params.put(AzureStackUtil.NAME,storageName);
      params.put(DESCRIPTION,VM_COMMON_NAME);
      params.put(AFFINITYGROUP,VM_COMMON_NAME);
      HttpResponseDecorator response=(HttpResponseDecorator)azureClient.createStorageAccount(params);
      azureClient.waitUntilComplete((String)azureClient.getRequestId(response));
    }
 catch (    Exception ex) {
      LOGGER.info("String_Node_Str");
    }
    try {
      String targetBlobContainerUri="String_Node_Str" + storageName + "String_Node_Str";
      String targetImageUri=targetBlobContainerUri + '/' + storageName+ "String_Node_Str";
      Map<String,String> params=new HashMap<>();
      params.put(AzureStackUtil.NAME,storageName);
      String keyJson=(String)azureClient.getStorageAccountKeys(params);
      JsonNode actualObj=MAPPER.readValue(keyJson,JsonNode.class);
      String storageAccountKey=actualObj.get("String_Node_Str").get("String_Node_Str").get("String_Node_Str").asText();
      AzureClientUtil.createBlobContainer(storageAccountKey,targetBlobContainerUri);
      AzureClientUtil.copyOsImage(storageAccountKey,baseImageUri,targetImageUri);
      AzureClientUtil.imageCopyProgress(storageAccountKey,targetImageUri);
      params=new HashMap<>();
      params.put(AzureStackUtil.NAME,IMAGE_NAME);
      params.put(OS,"String_Node_Str");
      params.put(MEDIALINK,targetImageUri);
      azureClient.addOsImage(params);
    }
 catch (    IOException e) {
      throw new InternalServerException("String_Node_Str");
    }
  }
  reactor.notify(ReactorConfig.PROVISION_SETUP_COMPLETE_EVENT,Event.wrap(new ProvisionSetupComplete(getCloudPlatform(),stack.getId()).withSetupProperty(CREDENTIAL,stack.getCredential()).withSetupProperty(EMAILASFOLDER,stack.getUser().emailAsFolder())));
}

Fixed version (ground truth):
@Override public void setupProvisioning(Stack stack){
  LOGGER.info("String_Node_Str",ReactorConfig.PROVISION_SETUP_COMPLETE_EVENT,stack.getId());
  Credential credential=stack.getCredential();
  String emailAsFolder=stack.getUser().emailAsFolder();
  String filePath=AzureCertificateService.getUserJksFileName(credential,emailAsFolder);
  File file=new File(filePath);
  AzureClient azureClient=new AzureClient(((AzureCredential)credential).getSubscriptionId(),file.getAbsolutePath(),((AzureCredential)credential).getJks());
  if (!azureClient.isImageAvailable(AzureStackUtil.getOsImageName(credential))) {
    String baseImageUri="String_Node_Str";
    String affinityGroupName=((AzureCredential)credential).getName().replaceAll("String_Node_Str","String_Node_Str");
    try {
      Map<String,String> params=new HashMap<>();
      params.put(AzureStackUtil.NAME,affinityGroupName);
      params.put(DESCRIPTION,VM_COMMON_NAME);
      params.put(LOCATION,"String_Node_Str");
      azureClient.createAffinityGroup(params);
    }
 catch (    Exception ex) {
      LOGGER.info("String_Node_Str");
    }
    String storageName=String.format("String_Node_Str",VM_COMMON_NAME,stack.getId());
    try {
      Map<String,String> params=new HashMap<>();
      params.put(AzureStackUtil.NAME,affinityGroupName);
      params.put(DESCRIPTION,VM_COMMON_NAME);
      params.put(AFFINITYGROUP,affinityGroupName);
      HttpResponseDecorator response=(HttpResponseDecorator)azureClient.createStorageAccount(params);
      azureClient.waitUntilComplete((String)azureClient.getRequestId(response));
    }
 catch (    Exception ex) {
      LOGGER.info("String_Node_Str");
    }
    try {
      String targetBlobContainerUri="String_Node_Str" + affinityGroupName + "String_Node_Str";
      String targetImageUri=targetBlobContainerUri + '/' + storageName+ "String_Node_Str";
      Map<String,String> params=new HashMap<>();
      params.put(AzureStackUtil.NAME,affinityGroupName);
      String keyJson=(String)azureClient.getStorageAccountKeys(params);
      JsonNode actualObj=MAPPER.readValue(keyJson,JsonNode.class);
      String storageAccountKey=actualObj.get("String_Node_Str").get("String_Node_Str").get("String_Node_Str").asText();
      AzureClientUtil.createBlobContainer(storageAccountKey,targetBlobContainerUri);
      AzureClientUtil.copyOsImage(storageAccountKey,baseImageUri,targetImageUri);
      AzureClientUtil.imageCopyProgress(storageAccountKey,targetImageUri);
      params=new HashMap<>();
      params.put(AzureStackUtil.NAME,AzureStackUtil.getOsImageName(credential));
      params.put(OS,"String_Node_Str");
      params.put(MEDIALINK,targetImageUri);
      azureClient.addOsImage(params);
    }
 catch (    IOException e) {
      throw new InternalServerException("String_Node_Str");
    }
  }
  reactor.notify(ReactorConfig.PROVISION_SETUP_COMPLETE_EVENT,Event.wrap(new ProvisionSetupComplete(getCloudPlatform(),stack.getId()).withSetupProperty(CREDENTIAL,stack.getCredential()).withSetupProperty(EMAILASFOLDER,stack.getUser().emailAsFolder())));
}