Program: 63977
Project: 63977
Buggy source:
@Override public Stack convert(StackJson source){
  Stack stack=new Stack();
  stack.setName(source.getName());
  stack.setUserName(source.getUserName());
  stack.setPassword(source.getPassword());
  stack.setPublicInAccount(source.isPublicInAccount());
  stack.setRegion(source.getRegion());
  stack.setOnFailureActionAction(source.getOnFailureAction());
  if (source.getAllowedSubnets() != null) {
    stack.setAllowedSubnets(convertSubnets(source.getAllowedSubnets()));
  }
  stack.addAllowedSubnets(securityService.getCloudbreakSubnets(stack));
  try {
    stack.setCredential(credentialRepository.findOne(source.getCredentialId()));
  }
 catch (  AccessDeniedException e) {
    throw new AccessDeniedException(String.format("String_Node_Str",source.getCredentialId()),e);
  }
  stack.setStatus(Status.REQUESTED);
  stack.setInstanceGroups(convertInstanceGroups(source.getInstanceGroups()));
  if (stack.getInstanceGroupsByType(GATEWAY).isEmpty()) {
    throw new BadRequestException("String_Node_Str");
  }
  int minNodeCount=ConsulUtils.ConsulServers.NODE_COUNT_LOW.getMin();
  int fullNodeCount=stack.getFullNodeCount();
  if (fullNodeCount < minNodeCount) {
    throw new BadRequestException(String.format("String_Node_Str",minNodeCount));
  }
  if (source.getImage() != null) {
    stack.setImage(source.getImage());
  }
 else {
    stack.setImage(prepareImage(stack));
  }
  int consulServers=getConsulServerCount(source,fullNodeCount);
  stack.setConsulServers(consulServers);
  if (source.getFailurePolicy() != null) {
    stack.setFailurePolicy(getConversionService().convert(source.getFailurePolicy(),FailurePolicy.class));
    FailurePolicy failurePolicy=stack.getFailurePolicy();
    validatFailurePolicy(stack,consulServers,failurePolicy);
  }
  stack.setParameters(source.getParameters());
  return stack;
}

Fixed version (ground truth):
@Override public Stack convert(StackJson source){
  Stack stack=new Stack();
  stack.setName(source.getName());
  stack.setUserName(source.getUserName());
  stack.setPassword(source.getPassword());
  stack.setPublicInAccount(source.isPublicInAccount());
  stack.setRegion(source.getRegion());
  stack.setOnFailureActionAction(source.getOnFailureAction());
  if (source.getAllowedSubnets() != null) {
    stack.setAllowedSubnets(convertSubnets(source.getAllowedSubnets(),stack));
  }
  stack.addAllowedSubnets(securityService.getCloudbreakSubnets(stack));
  try {
    stack.setCredential(credentialRepository.findOne(source.getCredentialId()));
  }
 catch (  AccessDeniedException e) {
    throw new AccessDeniedException(String.format("String_Node_Str",source.getCredentialId()),e);
  }
  stack.setStatus(Status.REQUESTED);
  stack.setInstanceGroups(convertInstanceGroups(source.getInstanceGroups(),stack));
  if (stack.getInstanceGroupsByType(GATEWAY).isEmpty()) {
    throw new BadRequestException("String_Node_Str");
  }
  int minNodeCount=ConsulUtils.ConsulServers.NODE_COUNT_LOW.getMin();
  int fullNodeCount=stack.getFullNodeCount();
  if (fullNodeCount < minNodeCount) {
    throw new BadRequestException(String.format("String_Node_Str",minNodeCount));
  }
  if (source.getImage() != null) {
    stack.setImage(source.getImage());
  }
 else {
    stack.setImage(prepareImage(stack));
  }
  int consulServers=getConsulServerCount(source,fullNodeCount);
  stack.setConsulServers(consulServers);
  if (source.getFailurePolicy() != null) {
    stack.setFailurePolicy(getConversionService().convert(source.getFailurePolicy(),FailurePolicy.class));
    FailurePolicy failurePolicy=stack.getFailurePolicy();
    validatFailurePolicy(stack,consulServers,failurePolicy);
  }
  stack.setParameters(source.getParameters());
  return stack;
}