Program: 63984
Project: 63984
Buggy source:
private void upScaleStack(UpdateInstancesRequest request,Stack stack) throws Exception {
  String userDataScript=userDataBuilder.build(stack.cloudPlatform(),stack.getHash(),stack.getConsulServers(),new HashMap<String,String>());
  if (stack.isCloudPlatformUsedWithTemplate()) {
    cloudPlatformConnectors.get(stack.cloudPlatform()).addInstances(stack,userDataScript,request.getScalingAdjustment(),request.getInstanceGroup());
  }
 else {
    ResourceBuilderInit resourceBuilderInit=resourceBuilderInits.get(stack.cloudPlatform());
    final ProvisionContextObject provisionContextObject=resourceBuilderInit.provisionInit(stack,userDataScript);
    for (    ResourceBuilder resourceBuilder : networkResourceBuilders.get(stack.cloudPlatform())) {
      provisionContextObject.getNetworkResources().addAll(stack.getResourcesByType(resourceBuilder.resourceType()));
    }
    List<Future<ResourceRequestResult>> futures=new ArrayList<>();
    final Set<ResourceRequestResult> resourceRequestResults=new HashSet<>();
    for (int i=stack.getFullNodeCount(); i < stack.getFullNodeCount() + request.getScalingAdjustment(); i++) {
      final int index=i;
      Future<ResourceRequestResult> submit=resourceBuilderExecutor.submit(UpScaleCallableBuilder.builder().withStack(stack).withStackUpdater(stackUpdater).withIndex(index).withProvisionContextObject(provisionContextObject).withInstanceResourceBuilders(instanceResourceBuilders).withInstanceGroup(request.getInstanceGroup()).build());
      futures.add(submit);
      if (provisionUtil.isRequestFullWithCloudPlatform(stack,futures.size() + 1)) {
        Map<FutureResult,List<ResourceRequestResult>> result=provisionUtil.waitForRequestToFinish(stack.getId(),futures);
        provisionUtil.checkErrorOccurred(result);
        resourceRequestResults.addAll(result.get(FutureResult.SUCCESS));
        futures=new ArrayList<>();
      }
    }
    Map<FutureResult,List<ResourceRequestResult>> result=provisionUtil.waitForRequestToFinish(stack.getId(),futures);
    provisionUtil.checkErrorOccurred(result);
    resourceRequestResults.addAll(result.get(FutureResult.SUCCESS));
    if (!stackRepository.findById(stack.getId()).isStackInDeletionPhase()) {
      LOGGER.info("String_Node_Str",ReactorConfig.ADD_INSTANCES_COMPLETE_EVENT);
      reactor.notify(ReactorConfig.ADD_INSTANCES_COMPLETE_EVENT,Event.wrap(new AddInstancesComplete(stack.cloudPlatform(),stack.getId(),collectResources(resourceRequestResults),request.getInstanceGroup())));
    }
  }
}

Fixed version (ground truth):
private void upScaleStack(UpdateInstancesRequest request,Stack stack) throws Exception {
  String userDataScript=userDataBuilder.build(stack.cloudPlatform(),stack.getHash(),stack.getConsulServers(),new HashMap<String,String>());
  if (stack.isCloudPlatformUsedWithTemplate()) {
    cloudPlatformConnectors.get(stack.cloudPlatform()).addInstances(stack,userDataScript,request.getScalingAdjustment(),request.getInstanceGroup());
  }
 else {
    ResourceBuilderInit resourceBuilderInit=resourceBuilderInits.get(stack.cloudPlatform());
    final ProvisionContextObject provisionContextObject=resourceBuilderInit.provisionInit(stack,userDataScript);
    for (    ResourceBuilder resourceBuilder : networkResourceBuilders.get(stack.cloudPlatform())) {
      provisionContextObject.getNetworkResources().addAll(stack.getResourcesByType(resourceBuilder.resourceType()));
    }
    List<Future<ResourceRequestResult>> futures=new ArrayList<>();
    final Set<ResourceRequestResult> successResourceRequestResults=new HashSet<>();
    final List<ResourceRequestResult> failedResourceRequestResults=new ArrayList<>();
    final Integer addNodeCount=request.getScalingAdjustment();
    for (int i=stack.getFullNodeCount(); i < stack.getFullNodeCount() + addNodeCount; i++) {
      final int index=i;
      Future<ResourceRequestResult> submit=resourceBuilderExecutor.submit(UpScaleCallableBuilder.builder().withStack(stack).withStackUpdater(stackUpdater).withIndex(index).withProvisionContextObject(provisionContextObject).withInstanceResourceBuilders(instanceResourceBuilders).withInstanceGroup(request.getInstanceGroup()).build());
      futures.add(submit);
      if (provisionUtil.isRequestFullWithCloudPlatform(stack,futures.size() + 1)) {
        Map<FutureResult,List<ResourceRequestResult>> result=provisionUtil.waitForRequestToFinish(stack.getId(),futures);
        successResourceRequestResults.addAll(result.get(FutureResult.SUCCESS));
        failedResourceRequestResults.addAll(result.get(FutureResult.FAILED));
        upscaleFailureHandlerService.handleFailure(stack,failedResourceRequestResults);
        futures=new ArrayList<>();
      }
    }
    Map<FutureResult,List<ResourceRequestResult>> result=provisionUtil.waitForRequestToFinish(stack.getId(),futures);
    successResourceRequestResults.addAll(result.get(FutureResult.SUCCESS));
    failedResourceRequestResults.addAll(result.get(FutureResult.FAILED));
    upscaleFailureHandlerService.handleFailure(stack,failedResourceRequestResults);
    if (!stackRepository.findById(stack.getId()).isStackInDeletionPhase()) {
      LOGGER.info("String_Node_Str",ReactorConfig.ADD_INSTANCES_COMPLETE_EVENT);
      reactor.notify(ReactorConfig.ADD_INSTANCES_COMPLETE_EVENT,Event.wrap(new AddInstancesComplete(stack.cloudPlatform(),stack.getId(),collectResources(successResourceRequestResults),request.getInstanceGroup())));
    }
  }
}