Program: 63836
Project: 63836
Buggy source:
@Override public void buildCluster(Stack stack){
  Cluster cluster=stack.getCluster();
  try {
    clusterService.updateCreationDateOnCluster(cluster);
    AmbariClient ambariClient=clientFactory.getAmbariClient(stack,stack.getCluster());
    Set<HostGroup> hostGroups=hostGroupService.getByCluster(cluster.getId());
    BlueprintPreparationObject blueprintPreparationObject=conversionService.convert(stack,BlueprintPreparationObject.class);
    Map<String,List<Map<String,String>>> hostGroupMappings=hostGroupAssociationBuilder.buildHostGroupAssociations(hostGroups);
    Set<HostMetadata> hostsInCluster=hostMetadataRepository.findHostsInCluster(cluster.getId());
    recipeEngine.executePostAmbariStartRecipes(stack,hostGroups);
    ambariRepositoryVersionService.setBaseRepoURL(stack.getName(),cluster.getId(),stack.getOrchestrator(),ambariClient);
    String blueprintText=centralBlueprintUpdater.getBlueprintText(blueprintPreparationObject);
    addBlueprint(stack.getId(),ambariClient,blueprintText,cluster.getTopologyValidation());
    cluster.setExtendedBlueprintText(blueprintText);
    clusterService.updateCluster(cluster);
    PollingResult waitForHostsResult=ambariPollingServiceProvider.hostsPollingService(stack,ambariClient,hostsInCluster);
    ambariClusterConnectorPollingResultChecker.checkPollingResult(waitForHostsResult,cloudbreakMessagesService.getMessage(AMBARI_CLUSTER_HOST_JOIN_FAILED.code()));
    ambariClusterTemplateService.addClusterTemplate(cluster,hostGroupMappings,ambariClient);
    Pair<PollingResult,Exception> pollingResult=ambariOperationService.waitForOperationsToStart(stack,ambariClient,singletonMap("String_Node_Str",1),START_OPERATION_STATE);
    String message=pollingResult.getRight() == null ? constructClusterFailedMessage(cluster.getId(),ambariClient) : pollingResult.getRight().getMessage();
    ambariClusterConnectorPollingResultChecker.checkPollingResult(pollingResult.getLeft(),message);
    Pair<PollingResult,Exception> pollingResultExceptionPair=ambariOperationService.waitForOperations(stack,ambariClient,new HashMap<String,Integer>(){
{
        put("String_Node_Str",1);
      }
    }
,INSTALL_AMBARI_PROGRESS_STATE);
    ambariClusterConnectorPollingResultChecker.checkPollingResult(pollingResultExceptionPair.getLeft(),constructClusterFailedMessage(cluster.getId(),ambariClient));
    recipeEngine.executePostInstall(stack);
    ambariSmartSenseCapturer.capture(0,ambariClient);
    cluster=ambariViewProvider.provideViewInformation(ambariClient,cluster);
    ambariClusterCreationSuccessHandler.handleClusterCreationSuccess(stack,cluster);
  }
 catch (  CancellationException cancellationException) {
    throw cancellationException;
  }
catch (  Exception e) {
    LOGGER.info("String_Node_Str",e.getMessage(),e);
    throw new AmbariOperationFailedException(e.getMessage(),e);
  }
}

Fixed version (ground truth):
@Override public void buildCluster(Stack stack){
  Cluster cluster=stack.getCluster();
  try {
    clusterService.updateCreationDateOnCluster(cluster);
    AmbariClient ambariClient=clientFactory.getAmbariClient(stack,stack.getCluster());
    Set<HostGroup> hostGroups=hostGroupService.getByCluster(cluster.getId());
    BlueprintPreparationObject blueprintPreparationObject=conversionService.convert(stack,BlueprintPreparationObject.class);
    Map<String,List<Map<String,String>>> hostGroupMappings=hostGroupAssociationBuilder.buildHostGroupAssociations(hostGroups);
    Set<HostMetadata> hostsInCluster=hostMetadataRepository.findHostsInCluster(cluster.getId());
    recipeEngine.executePostAmbariStartRecipes(stack,hostGroups);
    ambariRepositoryVersionService.setBaseRepoURL(stack.getName(),cluster.getId(),stack.getOrchestrator(),ambariClient);
    String blueprintText=centralBlueprintUpdater.getBlueprintText(blueprintPreparationObject);
    addBlueprint(stack.getId(),ambariClient,blueprintText,cluster.getTopologyValidation());
    cluster.setExtendedBlueprintText(blueprintText);
    clusterService.updateCluster(cluster);
    PollingResult waitForHostsResult=ambariPollingServiceProvider.hostsPollingService(stack,ambariClient,hostsInCluster);
    ambariClusterConnectorPollingResultChecker.checkPollingResult(waitForHostsResult,cloudbreakMessagesService.getMessage(AMBARI_CLUSTER_HOST_JOIN_FAILED.code()));
    ambariClusterTemplateService.addClusterTemplate(cluster,hostGroupMappings,ambariClient);
    Pair<PollingResult,Exception> pollingResult=ambariOperationService.waitForOperationsToStart(stack,ambariClient,singletonMap("String_Node_Str",1),START_OPERATION_STATE);
    String message=pollingResult.getRight() == null ? constructClusterFailedMessage(cluster.getId(),ambariClient) : pollingResult.getRight().getMessage();
    ambariClusterConnectorPollingResultChecker.checkPollingResult(pollingResult.getLeft(),message);
    Pair<PollingResult,Exception> pollingResultExceptionPair=ambariOperationService.waitForOperations(stack,ambariClient,new HashMap<String,Integer>(){
{
        put("String_Node_Str",1);
      }
    }
,INSTALL_AMBARI_PROGRESS_STATE);
    ambariClusterConnectorPollingResultChecker.checkPollingResult(pollingResultExceptionPair.getLeft(),constructClusterFailedMessage(cluster.getId(),ambariClient));
    recipeEngine.executePostInstallRecipes(stack,hostGroups);
    ambariSmartSenseCapturer.capture(0,ambariClient);
    cluster=ambariViewProvider.provideViewInformation(ambariClient,cluster);
    ambariClusterCreationSuccessHandler.handleClusterCreationSuccess(stack,cluster);
  }
 catch (  CancellationException cancellationException) {
    throw cancellationException;
  }
catch (  Exception e) {
    LOGGER.info("String_Node_Str",e.getMessage(),e);
    throw new AmbariOperationFailedException(e.getMessage(),e);
  }
}