Program: 63863
Project: 63863
Buggy source:
public Set<RecipeExecutionFailure> collectErrors(CloudbreakOrchestratorException exception,Map<HostGroup,List<RecipeModel>> hostgroupToRecipeMap,Set<InstanceGroup> instanceGroups){
  return exception.getNodesWithErrors().asMap().entrySet().stream().flatMap((  Entry<String,Collection<String>> nodeWithErrors) -> {
    Map<String,Optional<String>> errorsWithPhase=nodeWithErrors.getValue().stream().collect(Collectors.toMap(e -> e,this::getInstallPhase,(phase1,phase2) -> phase1.map(Optional::of).orElse(phase2)));
    return errorsWithPhase.entrySet().stream().filter(errorWithPhase -> errorWithPhase.getValue().isPresent()).map((    Entry<String,Optional<String>> errorWithPhase) -> StringUtils.substringBetween(errorWithPhase.getKey(),"String_Node_Str" + errorWithPhase.getValue().get() + '/',"String_Node_Str")).collect(Collectors.toMap(recipeName -> recipeName,recipeName -> getPossibleFailingHostgroupsByRecipeName(hostgroupToRecipeMap,recipeName),(hg1,hg2) -> Stream.concat(hg1.stream(),hg2.stream()).collect(Collectors.toSet()))).entrySet().stream().flatMap((    Entry<String,Set<String>> recipeWithHostgroups) -> recipeWithHostgroups.getValue().stream().map((    String hostGroup) -> {
      Optional<Recipe> recipe=getRecipeOfHostgroupByRecipeName(hostgroupToRecipeMap,recipeWithHostgroups.getKey(),hostGroup);
      Optional<InstanceMetaData> instanceMetaData=getInstanceMetaDataByHost(instanceGroups,nodeWithErrors.getKey(),hostGroup);
      if (recipe.isPresent() && instanceMetaData.isPresent()) {
        return new RecipeExecutionFailure(recipe.get(),instanceMetaData.get());
      }
      return null;
    }
).filter(Objects::nonNull));
  }
).collect(Collectors.toSet());
}

Fixed version (ground truth):
public Set<RecipeExecutionFailure> collectErrors(CloudbreakOrchestratorException exception,Map<HostGroup,List<RecipeModel>> hostgroupToRecipeMap,Set<InstanceGroup> instanceGroups){
  if (!canProcessExecutionFailure(exception)) {
    throw new CloudbreakServiceException("String_Node_Str",exception);
  }
  return exception.getNodesWithErrors().asMap().entrySet().stream().flatMap((  Entry<String,Collection<String>> nodeWithErrors) -> {
    Map<String,Optional<String>> errorsWithPhase=nodeWithErrors.getValue().stream().collect(Collectors.toMap(e -> e,this::getInstallPhase,(phase1,phase2) -> phase1.map(Optional::of).orElse(phase2)));
    return errorsWithPhase.entrySet().stream().filter(errorWithPhase -> errorWithPhase.getValue().isPresent()).map(this::errorWithPhaseToRecipeName).collect(Collectors.toMap(recipeName -> recipeName,recipeName -> getPossibleFailingHostgroupsByRecipeName(hostgroupToRecipeMap,recipeName),(hg1,hg2) -> Stream.concat(hg1.stream(),hg2.stream()).collect(Collectors.toSet()))).entrySet().stream().flatMap((    Entry<String,Set<String>> recipeWithHostgroups) -> recipeWithHostgroups.getValue().stream().map((    String hostGroup) -> {
      Optional<Recipe> recipe=getRecipeOfHostgroupByRecipeName(hostgroupToRecipeMap,recipeWithHostgroups.getKey(),hostGroup);
      Optional<InstanceMetaData> instanceMetaData=getInstanceMetaDataByHost(instanceGroups,nodeWithErrors.getKey(),hostGroup);
      if (recipe.isPresent() && instanceMetaData.isPresent()) {
        return new RecipeExecutionFailure(recipe.get(),instanceMetaData.get());
      }
      return null;
    }
).filter(Objects::nonNull));
  }
).collect(Collectors.toSet());
}