nus-yam/ex-repair huggingface dataset:
Program: 14208
Project: 14208
Buggy source:
public DescribeStackEventsResponseType describeStackEvents(DescribeStackEventsType request) throws CloudFormationException {
  DescribeStackEventsResponseType reply=request.getReply();
  try {
    final Context ctx=Contexts.lookup();
    checkActionPermission(PolicySpec.CLOUDFORMATION_DESCRIBESTACKEVENTS,ctx);
    User user=ctx.getUser();
    String userId=user.getUserId();
    String accountId=user.getAccount().getAccountNumber();
    String stackName=request.getStackName();
    if (stackName == null)     throw new ValidationErrorException("String_Node_Str");
    ArrayList<StackEvent> stackEventList=StackEventEntityManager.getStackEventsByNameOrId(stackName,accountId);
    StackEvents stackEvents=new StackEvents();
    stackEvents.setMember(stackEventList);
    DescribeStackEventsResult describeStackEventsResult=new DescribeStackEventsResult();
    describeStackEventsResult.setStackEvents(stackEvents);
    reply.setDescribeStackEventsResult(describeStackEventsResult);
  }
 catch (  Exception ex) {
    handleException(ex);
  }
  return reply;
}

Fixed version (ground truth):
public DescribeStackEventsResponseType describeStackEvents(DescribeStackEventsType request) throws CloudFormationException {
  DescribeStackEventsResponseType reply=request.getReply();
  try {
    final Context ctx=Contexts.lookup();
    checkActionPermission(PolicySpec.CLOUDFORMATION_DESCRIBESTACKEVENTS,ctx);
    User user=ctx.getUser();
    String userId=user.getUserId();
    String accountId=user.getAccount().getAccountNumber();
    String stackName=request.getStackName();
    if (stackName == null)     throw new ValidationErrorException("String_Node_Str");
    ArrayList<StackEvent> stackEventList=StackEventEntityManager.getStackEventsByNameOrId(stackName,accountId);
    StackEvents stackEvents=new StackEvents();
    stackEvents.setMember(stackEventList);
    DescribeStackEventsResult describeStackEventsResult=new DescribeStackEventsResult();
    describeStackEventsResult.setStackEvents(stackEvents);
    reply.setDescribeStackEventsResult(describeStackEventsResult);
  }
 catch (  Exception ex) {
    LOG.error(ex,ex);
    handleException(ex);
  }
  return reply;
}
Program: 14209
Project: 14209
Buggy source:
public DeleteStackResponseType deleteStack(DeleteStackType request) throws CloudFormationException {
  DeleteStackResponseType reply=request.getReply();
  try {
    final Context ctx=Contexts.lookup();
    checkActionPermission(PolicySpec.CLOUDFORMATION_DELETESTACK,ctx);
    User user=ctx.getUser();
    String userId=user.getUserId();
    String accountId=user.getAccount().getAccountNumber();
    String stackName=request.getStackName();
    if (stackName == null)     throw new ValidationErrorException("String_Node_Str");
    StackEntity stackEntity=StackEntityManager.getNonDeletedStackByNameOrId(stackName,accountId);
    if (stackEntity != null) {
      new StackDeletor(stackEntity,userId).start();
    }
  }
 catch (  Exception ex) {
    handleException(ex);
  }
  return reply;
}

Fixed version (ground truth):
public DeleteStackResponseType deleteStack(DeleteStackType request) throws CloudFormationException {
  DeleteStackResponseType reply=request.getReply();
  try {
    final Context ctx=Contexts.lookup();
    checkActionPermission(PolicySpec.CLOUDFORMATION_DELETESTACK,ctx);
    User user=ctx.getUser();
    String userId=user.getUserId();
    String accountId=user.getAccount().getAccountNumber();
    String stackName=request.getStackName();
    if (stackName == null)     throw new ValidationErrorException("String_Node_Str");
    StackEntity stackEntity=StackEntityManager.getNonDeletedStackByNameOrId(stackName,accountId);
    if (stackEntity != null) {
      new StackDeletor(stackEntity,userId).start();
    }
  }
 catch (  Exception ex) {
    LOG.error(ex,ex);
    handleException(ex);
  }
  return reply;
}
Program: 14212
Project: 14212
Buggy source:
public GetTemplateResponseType getTemplate(GetTemplateType request) throws CloudFormationException {
  GetTemplateResponseType reply=request.getReply();
  try {
    final Context ctx=Contexts.lookup();
    checkActionPermission(PolicySpec.CLOUDFORMATION_GETTEMPLATE,ctx);
    User user=ctx.getUser();
    String userId=user.getUserId();
    String accountId=user.getAccount().getAccountNumber();
    String stackName=request.getStackName();
    if (stackName == null) {
      throw new ValidationErrorException("String_Node_Str");
    }
    StackEntity stackEntity=StackEntityManager.getAnyStackByNameOrId(stackName,accountId);
    if (stackEntity == null) {
      throw new ValidationErrorException("String_Node_Str" + stackName + "String_Node_Str");
    }
    GetTemplateResult getTemplateResult=new GetTemplateResult();
    getTemplateResult.setTemplateBody(stackEntity.getTemplateBody());
    reply.setGetTemplateResult(getTemplateResult);
  }
 catch (  Exception ex) {
    handleException(ex);
  }
  return reply;
}

Fixed version (ground truth):
public GetTemplateResponseType getTemplate(GetTemplateType request) throws CloudFormationException {
  GetTemplateResponseType reply=request.getReply();
  try {
    final Context ctx=Contexts.lookup();
    checkActionPermission(PolicySpec.CLOUDFORMATION_GETTEMPLATE,ctx);
    User user=ctx.getUser();
    String userId=user.getUserId();
    String accountId=user.getAccount().getAccountNumber();
    String stackName=request.getStackName();
    if (stackName == null) {
      throw new ValidationErrorException("String_Node_Str");
    }
    StackEntity stackEntity=StackEntityManager.getAnyStackByNameOrId(stackName,accountId);
    if (stackEntity == null) {
      throw new ValidationErrorException("String_Node_Str" + stackName + "String_Node_Str");
    }
    GetTemplateResult getTemplateResult=new GetTemplateResult();
    getTemplateResult.setTemplateBody(stackEntity.getTemplateBody());
    reply.setGetTemplateResult(getTemplateResult);
  }
 catch (  Exception ex) {
    LOG.error(ex,ex);
    handleException(ex);
  }
  return reply;
}
Program: 14215
Project: 14215
Buggy source:
public GetStackPolicyResponseType getStackPolicy(GetStackPolicyType request) throws CloudFormationException {
  GetStackPolicyResponseType reply=request.getReply();
  try {
    final Context ctx=Contexts.lookup();
    checkActionPermission(PolicySpec.CLOUDFORMATION_GETSTACKPOLICY,ctx);
    User user=ctx.getUser();
    String userId=user.getUserId();
    String accountId=user.getAccount().getAccountNumber();
    String stackName=request.getStackName();
    if (stackName == null) {
      throw new ValidationErrorException("String_Node_Str");
    }
    StackEntity stackEntity=StackEntityManager.getAnyStackByNameOrId(stackName,accountId);
    if (stackEntity == null) {
      throw new ValidationErrorException("String_Node_Str" + stackName + "String_Node_Str");
    }
    GetStackPolicyResult getStackPolicyResult=new GetStackPolicyResult();
    getStackPolicyResult.setStackPolicyBody(stackEntity.getStackPolicy());
    reply.setGetStackPolicyResult(getStackPolicyResult);
  }
 catch (  Exception ex) {
    handleException(ex);
  }
  return reply;
}

Fixed version (ground truth):
public GetStackPolicyResponseType getStackPolicy(GetStackPolicyType request) throws CloudFormationException {
  GetStackPolicyResponseType reply=request.getReply();
  try {
    final Context ctx=Contexts.lookup();
    checkActionPermission(PolicySpec.CLOUDFORMATION_GETSTACKPOLICY,ctx);
    User user=ctx.getUser();
    String userId=user.getUserId();
    String accountId=user.getAccount().getAccountNumber();
    String stackName=request.getStackName();
    if (stackName == null) {
      throw new ValidationErrorException("String_Node_Str");
    }
    StackEntity stackEntity=StackEntityManager.getAnyStackByNameOrId(stackName,accountId);
    if (stackEntity == null) {
      throw new ValidationErrorException("String_Node_Str" + stackName + "String_Node_Str");
    }
    GetStackPolicyResult getStackPolicyResult=new GetStackPolicyResult();
    getStackPolicyResult.setStackPolicyBody(stackEntity.getStackPolicy());
    reply.setGetStackPolicyResult(getStackPolicyResult);
  }
 catch (  Exception ex) {
    LOG.error(ex,ex);
    handleException(ex);
  }
  return reply;
}
Program: 14217
Project: 14217
Buggy source:
public SetStackPolicyResponseType setStackPolicy(SetStackPolicyType request) throws CloudFormationException {
  SetStackPolicyResponseType reply=request.getReply();
  try {
    final Context ctx=Contexts.lookup();
    checkActionPermission(PolicySpec.CLOUDFORMATION_SETSTACKPOLICY,ctx);
    User user=ctx.getUser();
    String userId=user.getUserId();
    String accountId=user.getAccount().getAccountNumber();
    final String stackName=request.getStackName();
    final String stackPolicyBody=request.getStackPolicyBody();
    if (request.getStackPolicyURL() != null) {
      throw new ValidationErrorException("String_Node_Str");
    }
    if (stackName == null)     throw new ValidationErrorException("String_Node_Str");
    StackEntity stackEntity=StackEntityManager.getAnyStackByNameOrId(stackName,accountId);
    if (stackEntity == null) {
      throw new ValidationErrorException("String_Node_Str" + stackName + "String_Node_Str");
    }
    stackEntity.setStackPolicy(stackPolicyBody);
    StackEntityManager.updateStack(stackEntity);
  }
 catch (  Exception ex) {
    handleException(ex);
  }
  return reply;
}

Fixed version (ground truth):
public SetStackPolicyResponseType setStackPolicy(SetStackPolicyType request) throws CloudFormationException {
  SetStackPolicyResponseType reply=request.getReply();
  try {
    final Context ctx=Contexts.lookup();
    checkActionPermission(PolicySpec.CLOUDFORMATION_SETSTACKPOLICY,ctx);
    User user=ctx.getUser();
    String userId=user.getUserId();
    String accountId=user.getAccount().getAccountNumber();
    final String stackName=request.getStackName();
    final String stackPolicyBody=request.getStackPolicyBody();
    if (request.getStackPolicyURL() != null) {
      throw new ValidationErrorException("String_Node_Str");
    }
    if (stackName == null)     throw new ValidationErrorException("String_Node_Str");
    StackEntity stackEntity=StackEntityManager.getAnyStackByNameOrId(stackName,accountId);
    if (stackEntity == null) {
      throw new ValidationErrorException("String_Node_Str" + stackName + "String_Node_Str");
    }
    stackEntity.setStackPolicy(stackPolicyBody);
    StackEntityManager.updateStack(stackEntity);
  }
 catch (  Exception ex) {
    LOG.error(ex,ex);
    handleException(ex);
  }
  return reply;
}
Program: 14218
Project: 14218
Buggy source:
public UpdateStackResponseType updateStack(UpdateStackType request) throws CloudFormationException {
  UpdateStackResponseType reply=request.getReply();
  try {
    final Context ctx=Contexts.lookup();
    checkActionPermission(PolicySpec.CLOUDFORMATION_UPDATESTACK,ctx);
  }
 catch (  Exception ex) {
    handleException(ex);
  }
  return reply;
}

Fixed version (ground truth):
public UpdateStackResponseType updateStack(UpdateStackType request) throws CloudFormationException {
  UpdateStackResponseType reply=request.getReply();
  try {
    final Context ctx=Contexts.lookup();
    checkActionPermission(PolicySpec.CLOUDFORMATION_UPDATESTACK,ctx);
  }
 catch (  Exception ex) {
    LOG.error(ex,ex);
    handleException(ex);
  }
  return reply;
}
Program: 14221
Project: 14221
Buggy source:
public CancelUpdateStackResponseType cancelUpdateStack(CancelUpdateStackType request) throws CloudFormationException {
  CancelUpdateStackResponseType reply=request.getReply();
  try {
    final Context ctx=Contexts.lookup();
    checkActionPermission(PolicySpec.CLOUDFORMATION_CANCELUPDATESTACK,ctx);
  }
 catch (  Exception ex) {
    handleException(ex);
  }
  return reply;
}

Fixed version (ground truth):
public CancelUpdateStackResponseType cancelUpdateStack(CancelUpdateStackType request) throws CloudFormationException {
  CancelUpdateStackResponseType reply=request.getReply();
  try {
    final Context ctx=Contexts.lookup();
    checkActionPermission(PolicySpec.CLOUDFORMATION_CANCELUPDATESTACK,ctx);
  }
 catch (  Exception ex) {
    LOG.error(ex,ex);
    handleException(ex);
  }
  return reply;
}
Program: 14222
Project: 14222
Buggy source:
public EstimateTemplateCostResponseType estimateTemplateCost(EstimateTemplateCostType request) throws CloudFormationException {
  EstimateTemplateCostResponseType reply=request.getReply();
  try {
    final Context ctx=Contexts.lookup();
    checkActionPermission(PolicySpec.CLOUDFORMATION_ESTIMATETEMPLATECOST,ctx);
  }
 catch (  Exception ex) {
    handleException(ex);
  }
  return reply;
}

Fixed version (ground truth):
public EstimateTemplateCostResponseType estimateTemplateCost(EstimateTemplateCostType request) throws CloudFormationException {
  EstimateTemplateCostResponseType reply=request.getReply();
  try {
    final Context ctx=Contexts.lookup();
    checkActionPermission(PolicySpec.CLOUDFORMATION_ESTIMATETEMPLATECOST,ctx);
  }
 catch (  Exception ex) {
    LOG.error(ex,ex);
    handleException(ex);
  }
  return reply;
}
Program: 14223
Project: 14223
Buggy source:
public static String getStringFromJsonNode(JsonNode jsonNode){
  return (jsonNode == null) ? null : jsonNode.toString();
}

Fixed version (ground truth):
public static String getStringFromJsonNode(JsonNode jsonNode){
  return (jsonNode == null || jsonNode.isTextual() && jsonNode.textValue() == null) ? null : jsonNode.toString();
}
Program: 14224
Project: 14224
Buggy source:
public DescribeStackEventsResponseType describeStackEvents(DescribeStackEventsType request) throws CloudFormationException {
  DescribeStackEventsResponseType reply=request.getReply();
  return reply;
}

Fixed version (ground truth):
public DescribeStackEventsResponseType describeStackEvents(DescribeStackEventsType request) throws CloudFormationException {
  DescribeStackEventsResponseType reply=request.getReply();
  try {
    final Context ctx=Contexts.lookup();
    checkActionPermission(PolicySpec.CLOUDFORMATION_DESCRIBESTACKEVENTS,ctx);
    User user=ctx.getUser();
    String userId=user.getUserId();
    String accountId=user.getAccount().getAccountNumber();
    String stackName=request.getStackName();
    if (stackName == null)     throw new ValidationErrorException("String_Node_Str");
    ArrayList<StackEvent> stackEventList=StackEventEntityManager.getStackEventsByNameOrId(stackName,accountId);
    StackEvents stackEvents=new StackEvents();
    stackEvents.setMember(stackEventList);
    DescribeStackEventsResult describeStackEventsResult=new DescribeStackEventsResult();
    describeStackEventsResult.setStackEvents(stackEvents);
    reply.setDescribeStackEventsResult(describeStackEventsResult);
  }
 catch (  Exception ex) {
    handleException(ex);
  }
  return reply;
}
Program: 14225
Project: 14225
Buggy source:
public DeleteStackResponseType deleteStack(DeleteStackType request) throws CloudFormationException {
  DeleteStackResponseType reply=request.getReply();
  try {
    final Context ctx=Contexts.lookup();
    User user=ctx.getUser();
    String userId=user.getUserId();
    String accountId=user.getAccount().getAccountNumber();
    String stackName=request.getStackName();
    if (stackName == null)     throw new ValidationErrorException("String_Node_Str");
    StackEntity stackEntity=StackEntityManager.getStackByNameOrId(stackName,accountId);
    if (stackEntity == null)     throw new ValidationErrorException("String_Node_Str" + stackName + "String_Node_Str");
    new StackDeletor(stackEntity,userId).start();
  }
 catch (  Exception ex) {
    LOG.error(ex,ex);
  }
  return reply;
}

Fixed version (ground truth):
public DeleteStackResponseType deleteStack(DeleteStackType request) throws CloudFormationException {
  DeleteStackResponseType reply=request.getReply();
  try {
    final Context ctx=Contexts.lookup();
    checkActionPermission(PolicySpec.CLOUDFORMATION_DELETESTACK,ctx);
    User user=ctx.getUser();
    String userId=user.getUserId();
    String accountId=user.getAccount().getAccountNumber();
    String stackName=request.getStackName();
    if (stackName == null)     throw new ValidationErrorException("String_Node_Str");
    StackEntity stackEntity=StackEntityManager.getNonDeletedStackByNameOrId(stackName,accountId);
    if (stackEntity != null) {
      new StackDeletor(stackEntity,userId).start();
    }
  }
 catch (  Exception ex) {
    handleException(ex);
  }
  return reply;
}
Program: 14226
Project: 14226
Buggy source:
public DescribeStackResourceResponseType describeStackResource(DescribeStackResourceType request) throws CloudFormationException {
  DescribeStackResourceResponseType reply=request.getReply();
  return reply;
}

Fixed version (ground truth):
public DescribeStackResourceResponseType describeStackResource(DescribeStackResourceType request) throws CloudFormationException {
  DescribeStackResourceResponseType reply=request.getReply();
  try {
    final Context ctx=Contexts.lookup();
    checkActionPermission(PolicySpec.CLOUDFORMATION_DESCRIBESTACKRESOURCE,ctx);
    User user=ctx.getUser();
    String userId=user.getUserId();
    String accountId=user.getAccount().getAccountNumber();
    String stackName=request.getStackName();
    if (stackName == null)     throw new ValidationErrorException("String_Node_Str");
    String logicalResourceId=request.getLogicalResourceId();
    if (logicalResourceId == null)     throw new ValidationErrorException("String_Node_Str");
    StackResourceEntity stackResourceEntity=StackResourceEntityManager.describeStackResource(accountId,stackName,logicalResourceId);
    StackResourceDetail stackResourceDetail=new StackResourceDetail();
    stackResourceDetail.setDescription(stackResourceEntity.getDescription());
    stackResourceDetail.setLastUpdatedTimestamp(stackResourceEntity.getLastUpdateTimestamp());
    stackResourceDetail.setLogicalResourceId(stackResourceEntity.getLogicalResourceId());
    stackResourceDetail.setMetadata(stackResourceEntity.getMetadataJson());
    stackResourceDetail.setPhysicalResourceId(stackResourceEntity.getPhysicalResourceId());
    stackResourceDetail.setResourceStatus(stackResourceEntity.getResourceStatus() == null ? null : stackResourceEntity.getResourceStatus().toString());
    stackResourceDetail.setResourceStatusReason(stackResourceEntity.getResourceStatusReason());
    stackResourceDetail.setResourceType(stackResourceEntity.getResourceType());
    stackResourceDetail.setStackId(stackResourceEntity.getStackId());
    stackResourceDetail.setStackName(stackResourceEntity.getStackName());
    DescribeStackResourceResult describeStackResourceResult=new DescribeStackResourceResult();
    describeStackResourceResult.setStackResourceDetail(stackResourceDetail);
    reply.setDescribeStackResourceResult(describeStackResourceResult);
  }
 catch (  Exception ex) {
    handleException(ex);
  }
  return reply;
}
Program: 14228
Project: 14228
Buggy source:
public GetTemplateResponseType getTemplate(GetTemplateType request) throws CloudFormationException {
  GetTemplateResponseType reply=request.getReply();
  return reply;
}

Fixed version (ground truth):
public GetTemplateResponseType getTemplate(GetTemplateType request) throws CloudFormationException {
  GetTemplateResponseType reply=request.getReply();
  try {
    final Context ctx=Contexts.lookup();
    checkActionPermission(PolicySpec.CLOUDFORMATION_GETTEMPLATE,ctx);
    User user=ctx.getUser();
    String userId=user.getUserId();
    String accountId=user.getAccount().getAccountNumber();
    String stackName=request.getStackName();
    if (stackName == null) {
      throw new ValidationErrorException("String_Node_Str");
    }
    StackEntity stackEntity=StackEntityManager.getAnyStackByNameOrId(stackName,accountId);
    if (stackEntity == null) {
      throw new ValidationErrorException("String_Node_Str" + stackName + "String_Node_Str");
    }
    GetTemplateResult getTemplateResult=new GetTemplateResult();
    getTemplateResult.setTemplateBody(stackEntity.getTemplateBody());
    reply.setGetTemplateResult(getTemplateResult);
  }
 catch (  Exception ex) {
    handleException(ex);
  }
  return reply;
}
Program: 14229
Project: 14229
Buggy source:
public ValidateTemplateResponseType validateTemplate(ValidateTemplateType request) throws CloudFormationException {
  ValidateTemplateResponseType reply=request.getReply();
  return reply;
}

Fixed version (ground truth):
public ValidateTemplateResponseType validateTemplate(ValidateTemplateType request) throws CloudFormationException {
  ValidateTemplateResponseType reply=request.getReply();
  try {
    final Context ctx=Contexts.lookup();
    checkActionPermission(PolicySpec.CLOUDFORMATION_VALIDATETEMPLATE,ctx);
  }
 catch (  Exception ex) {
    handleException(ex);
  }
  return reply;
}
Program: 14231
Project: 14231
Buggy source:
public GetStackPolicyResponseType getStackPolicy(GetStackPolicyType request) throws CloudFormationException {
  GetStackPolicyResponseType reply=request.getReply();
  return reply;
}

Fixed version (ground truth):
public GetStackPolicyResponseType getStackPolicy(GetStackPolicyType request) throws CloudFormationException {
  GetStackPolicyResponseType reply=request.getReply();
  try {
    final Context ctx=Contexts.lookup();
    checkActionPermission(PolicySpec.CLOUDFORMATION_GETSTACKPOLICY,ctx);
    User user=ctx.getUser();
    String userId=user.getUserId();
    String accountId=user.getAccount().getAccountNumber();
    String stackName=request.getStackName();
    if (stackName == null) {
      throw new ValidationErrorException("String_Node_Str");
    }
    StackEntity stackEntity=StackEntityManager.getAnyStackByNameOrId(stackName,accountId);
    if (stackEntity == null) {
      throw new ValidationErrorException("String_Node_Str" + stackName + "String_Node_Str");
    }
    GetStackPolicyResult getStackPolicyResult=new GetStackPolicyResult();
    getStackPolicyResult.setStackPolicyBody(stackEntity.getStackPolicy());
    reply.setGetStackPolicyResult(getStackPolicyResult);
  }
 catch (  Exception ex) {
    handleException(ex);
  }
  return reply;
}
Program: 14233
Project: 14233
Buggy source:
public SetStackPolicyResponseType setStackPolicy(SetStackPolicyType request) throws CloudFormationException {
  SetStackPolicyResponseType reply=request.getReply();
  return reply;
}

Fixed version (ground truth):
public SetStackPolicyResponseType setStackPolicy(SetStackPolicyType request) throws CloudFormationException {
  SetStackPolicyResponseType reply=request.getReply();
  try {
    final Context ctx=Contexts.lookup();
    checkActionPermission(PolicySpec.CLOUDFORMATION_SETSTACKPOLICY,ctx);
    User user=ctx.getUser();
    String userId=user.getUserId();
    String accountId=user.getAccount().getAccountNumber();
    final String stackName=request.getStackName();
    final String stackPolicyBody=request.getStackPolicyBody();
    if (request.getStackPolicyURL() != null) {
      throw new ValidationErrorException("String_Node_Str");
    }
    if (stackName == null)     throw new ValidationErrorException("String_Node_Str");
    StackEntity stackEntity=StackEntityManager.getAnyStackByNameOrId(stackName,accountId);
    if (stackEntity == null) {
      throw new ValidationErrorException("String_Node_Str" + stackName + "String_Node_Str");
    }
    stackEntity.setStackPolicy(stackPolicyBody);
    StackEntityManager.updateStack(stackEntity);
  }
 catch (  Exception ex) {
    handleException(ex);
  }
  return reply;
}
Program: 14234
Project: 14234
Buggy source:
public UpdateStackResponseType updateStack(UpdateStackType request) throws CloudFormationException {
  UpdateStackResponseType reply=request.getReply();
  return reply;
}

Fixed version (ground truth):
public UpdateStackResponseType updateStack(UpdateStackType request) throws CloudFormationException {
  UpdateStackResponseType reply=request.getReply();
  try {
    final Context ctx=Contexts.lookup();
    checkActionPermission(PolicySpec.CLOUDFORMATION_UPDATESTACK,ctx);
  }
 catch (  Exception ex) {
    handleException(ex);
  }
  return reply;
}
Program: 14235
Project: 14235
Buggy source:
public DescribeStackResourcesResponseType describeStackResources(DescribeStackResourcesType request) throws CloudFormationException {
  DescribeStackResourcesResponseType reply=request.getReply();
  return reply;
}

Fixed version (ground truth):
public DescribeStackResourcesResponseType describeStackResources(DescribeStackResourcesType request) throws CloudFormationException {
  DescribeStackResourcesResponseType reply=request.getReply();
  try {
    final Context ctx=Contexts.lookup();
    checkActionPermission(PolicySpec.CLOUDFORMATION_DESCRIBESTACKRESOURCES,ctx);
    User user=ctx.getUser();
    String userId=user.getUserId();
    String accountId=user.getAccount().getAccountNumber();
    String stackName=request.getStackName();
    String logicalResourceId=request.getLogicalResourceId();
    String physicalResourceId=request.getPhysicalResourceId();
    if (stackName != null && logicalResourceId != null) {
      throw new ValidationErrorException("String_Node_Str");
    }
    if (stackName == null && logicalResourceId == null) {
      throw new ValidationErrorException("String_Node_Str");
    }
    ArrayList<StackResource> stackResourceList=Lists.newArrayList();
    List<StackResourceEntity> stackResourceEntityList=StackResourceEntityManager.describeStackResources(accountId,stackName,physicalResourceId,logicalResourceId);
    if (stackResourceEntityList != null) {
      for (      StackResourceEntity stackResourceEntity : stackResourceEntityList) {
        StackResource stackResource=new StackResource();
        stackResource.setDescription(stackResourceEntity.getDescription());
        stackResource.setLogicalResourceId(stackResourceEntity.getLogicalResourceId());
        stackResource.setPhysicalResourceId(stackResourceEntity.getPhysicalResourceId());
        stackResource.setResourceStatus(stackResourceEntity.getResourceStatus().toString());
        stackResource.setResourceStatusReason(stackResourceEntity.getResourceStatusReason());
        stackResource.setResourceType(stackResourceEntity.getResourceType());
        stackResource.setStackId(stackResourceEntity.getStackId());
        stackResource.setStackName(stackResourceEntity.getStackName());
        stackResource.setTimestamp(stackResourceEntity.getLastUpdateTimestamp());
        stackResourceList.add(stackResource);
      }
    }
    DescribeStackResourcesResult describeStackResourcesResult=new DescribeStackResourcesResult();
    StackResources stackResources=new StackResources();
    stackResources.setMember(stackResourceList);
    describeStackResourcesResult.setStackResources(stackResources);
    reply.setDescribeStackResourcesResult(describeStackResourcesResult);
  }
 catch (  Exception ex) {
    handleException(ex);
  }
  return reply;
}
Program: 14236
Project: 14236
Buggy source:
public ListStackResourcesResponseType listStackResources(ListStackResourcesType request) throws CloudFormationException {
  ListStackResourcesResponseType reply=request.getReply();
  return reply;
}

Fixed version (ground truth):
public ListStackResourcesResponseType listStackResources(ListStackResourcesType request) throws CloudFormationException {
  ListStackResourcesResponseType reply=request.getReply();
  try {
    final Context ctx=Contexts.lookup();
    checkActionPermission(PolicySpec.CLOUDFORMATION_LISTSTACKRESOURCES,ctx);
    User user=ctx.getUser();
    String userId=user.getUserId();
    String accountId=user.getAccount().getAccountNumber();
    String stackName=request.getStackName();
    if (stackName == null) {
      throw new ValidationErrorException("String_Node_Str");
    }
    ArrayList<StackResourceSummary> stackResourceSummaryList=Lists.newArrayList();
    List<StackResourceEntity> stackResourceEntityList=StackResourceEntityManager.listStackResources(accountId,stackName);
    if (stackResourceEntityList != null) {
      for (      StackResourceEntity stackResourceEntity : stackResourceEntityList) {
        StackResourceSummary stackResourceSummary=new StackResourceSummary();
        stackResourceSummary.setLogicalResourceId(stackResourceEntity.getLogicalResourceId());
        stackResourceSummary.setPhysicalResourceId(stackResourceEntity.getPhysicalResourceId());
        stackResourceSummary.setResourceStatus(stackResourceEntity.getResourceStatus().toString());
        stackResourceSummary.setResourceStatusReason(stackResourceEntity.getResourceStatusReason());
        stackResourceSummary.setResourceType(stackResourceEntity.getResourceType());
        stackResourceSummary.setLastUpdatedTimestamp(stackResourceEntity.getLastUpdateTimestamp());
        stackResourceSummaryList.add(stackResourceSummary);
      }
    }
    ListStackResourcesResult listStackResourcesResult=new ListStackResourcesResult();
    StackResourceSummaries stackResourceSummaries=new StackResourceSummaries();
    stackResourceSummaries.setMember(stackResourceSummaryList);
    listStackResourcesResult.setStackResourceSummaries(stackResourceSummaries);
    reply.setListStackResourcesResult(listStackResourcesResult);
  }
 catch (  Exception ex) {
    handleException(ex);
  }
  return reply;
}
Program: 14237
Project: 14237
Buggy source:
public CancelUpdateStackResponseType cancelUpdateStack(CancelUpdateStackType request) throws CloudFormationException {
  CancelUpdateStackResponseType reply=request.getReply();
  return reply;
}

Fixed version (ground truth):
public CancelUpdateStackResponseType cancelUpdateStack(CancelUpdateStackType request) throws CloudFormationException {
  CancelUpdateStackResponseType reply=request.getReply();
  try {
    final Context ctx=Contexts.lookup();
    checkActionPermission(PolicySpec.CLOUDFORMATION_CANCELUPDATESTACK,ctx);
  }
 catch (  Exception ex) {
    handleException(ex);
  }
  return reply;
}
Program: 14238
Project: 14238
Buggy source:
public EstimateTemplateCostResponseType estimateTemplateCost(EstimateTemplateCostType request) throws CloudFormationException {
  EstimateTemplateCostResponseType reply=request.getReply();
  return reply;
}

Fixed version (ground truth):
public EstimateTemplateCostResponseType estimateTemplateCost(EstimateTemplateCostType request) throws CloudFormationException {
  EstimateTemplateCostResponseType reply=request.getReply();
  try {
    final Context ctx=Contexts.lookup();
    checkActionPermission(PolicySpec.CLOUDFORMATION_ESTIMATETEMPLATECOST,ctx);
  }
 catch (  Exception ex) {
    handleException(ex);
  }
  return reply;
}
Program: 14239
Project: 14239
Buggy source:
public static List<StackEntity> describeStacks(String accountId,String stackNameOrId){
  List<StackEntity> returnValue=Lists.newArrayList();
  try (TransactionResource db=Entities.transactionFor(StackEntity.class)){
    Criteria criteria=Entities.createCriteria(StackEntity.class).add(Restrictions.eq("String_Node_Str",accountId)).add(Restrictions.or(Restrictions.eq("String_Node_Str",stackNameOrId),Restrictions.eq("String_Node_Str",stackNameOrId))).add(Restrictions.eq("String_Node_Str",Boolean.FALSE));
    returnValue=criteria.list();
    db.commit();
  }
   return returnValue;
}

Fixed version (ground truth):
public static List<StackEntity> describeStacks(String accountId,String stackNameOrId){
  List<StackEntity> returnValue=Lists.newArrayList();
  try (TransactionResource db=Entities.transactionFor(StackEntity.class)){
    Criteria criteria=Entities.createCriteria(StackEntity.class).add(Restrictions.eq("String_Node_Str",accountId)).add(Restrictions.or(Restrictions.and(Restrictions.eq("String_Node_Str",Boolean.FALSE),Restrictions.eq("String_Node_Str",stackNameOrId)),Restrictions.eq("String_Node_Str",stackNameOrId)));
    returnValue=criteria.list();
    db.commit();
  }
   return returnValue;
}
Program: 14242
Project: 14242
Buggy source:
@Override public HeadObjectResponseType headObject(HeadObjectType request) throws S3Exception {
  ObjectEntity objectEntity=getObjectEntityAndCheckPermissions(request,request.getVersionId());
  if (objectEntity.getIsDeleteMarker()) {
    throw new NoSuchKeyException(request.getKey());
  }
  HeadObjectResponseType reply=request.getReply();
  request.setKey(objectEntity.getObjectUuid());
  request.setBucket(objectEntity.getBucket().getBucketUuid());
  try {
    HeadObjectResponseType backendReply=ospClient.headObject(request);
    reply.setMetaData(backendReply.getMetaData());
  }
 catch (  S3Exception e) {
    LOG.warn("String_Node_Str",e);
    throw new InternalErrorException(e);
  }
  reply.setLastModified(objectEntity.getObjectModifiedTimestamp());
  reply.setSize(objectEntity.getSize());
  reply.setVersionId(objectEntity.getVersionId());
  reply.setEtag(objectEntity.geteTag());
  reply.setVersionId(objectEntity.getVersionId());
  return reply;
}

Fixed version (ground truth):
@Override public HeadObjectResponseType headObject(HeadObjectType request) throws S3Exception {
  ObjectEntity objectEntity=getObjectEntityAndCheckPermissions(request,request.getVersionId());
  if (objectEntity.getIsDeleteMarker()) {
    throw new NoSuchKeyException(request.getKey());
  }
  HeadObjectResponseType reply=request.getReply();
  request.setKey(objectEntity.getObjectUuid());
  request.setBucket(objectEntity.getBucket().getBucketUuid());
  final String originalVersionId=request.getVersionId();
  try {
    request.setVersionId(null);
    HeadObjectResponseType backendReply=ospClient.headObject(request);
    reply.setMetaData(backendReply.getMetaData());
  }
 catch (  S3Exception e) {
    LOG.warn("String_Node_Str",e);
    throw new InternalErrorException(e);
  }
  reply.setLastModified(objectEntity.getObjectModifiedTimestamp());
  reply.setSize(objectEntity.getSize());
  reply.setVersionId(objectEntity.getVersionId());
  reply.setEtag(objectEntity.geteTag());
  reply.setVersionId(objectEntity.getVersionId());
  return reply;
}
Program: 14244
Project: 14244
Buggy source:
public static ServiceConfiguration lookup(final Class<? extends ComponentId> compClass,final Partition... maybePartition){
  final ComponentId compId=ComponentIds.lookup(compClass);
  final Partition partition=((maybePartition != null) && (maybePartition.length > 0) ? (compId.isPartitioned() ? maybePartition[0] : null) : null);
  ServiceConfiguration res=Topology.getInstance().getServices().get(ServiceKey.create(ComponentIds.lookup(compClass),partition));
  if (res == null && !compClass.equals(compId.partitionParent().getClass())) {
    ServiceConfiguration parent=Topology.getInstance().getServices().get(ServiceKey.create(compId.partitionParent(),null));
    Partition fakePartition=Partitions.lookupInternal(ServiceConfigurations.createEphemeral(compId,parent.getInetAddress()));
    res=Topology.getInstance().getServices().get(ServiceKey.create(compId,fakePartition));
  }
  String err="String_Node_Str" + compClass.getSimpleName() + (partition != null ? "String_Node_Str" + partition : "String_Node_Str");
  if (res == null) {
    throw new NoSuchElementException(err);
  }
 else   if (!Component.State.ENABLED.apply(res)) {
    throw new NoSuchElementException(err + "String_Node_Str");
  }
 else {
    return res;
  }
}

Fixed version (ground truth):
public static ServiceConfiguration lookup(final Class<? extends ComponentId> compClass,final Partition... maybePartition){
  final ComponentId compId=ComponentIds.lookup(compClass);
  final Partition partition=((maybePartition != null) && (maybePartition.length > 0) ? (compId.isPartitioned() ? maybePartition[0] : null) : null);
  ServiceConfiguration res=Topology.getInstance().getServices().get(ServiceKey.create(ComponentIds.lookup(compClass),partition));
  if (res == null && !compClass.equals(compId.partitionParent().getClass())) {
    try {
      ServiceConfiguration parent=Topology.getInstance().getServices().get(ServiceKey.create(compId.partitionParent(),null));
      Partition fakePartition=Partitions.lookupInternal(ServiceConfigurations.createEphemeral(compId,parent.getInetAddress()));
      res=Topology.getInstance().getServices().get(ServiceKey.create(compId,fakePartition));
    }
 catch (    RuntimeException e) {
      res=null;
    }
  }
  String err="String_Node_Str" + compClass.getSimpleName() + (partition != null ? "String_Node_Str" + partition : "String_Node_Str");
  if (res == null) {
    throw new NoSuchElementException(err);
  }
 else   if (!Component.State.ENABLED.apply(res)) {
    throw new NoSuchElementException(err + "String_Node_Str");
  }
 else {
    return res;
  }
}
Program: 14246
Project: 14246
Buggy source:
private static void validateArgTypesWherePossible(JsonNode jsonNode,boolean inConditionsSection) throws CloudFormationException {
  if (jsonNode != null) {
    if (jsonNode.isArray()) {
      for (int i=0; i < jsonNode.size(); i++) {
        validateConditionSectionArgTypesWherePossible(jsonNode.get(i));
      }
    }
 else     if (jsonNode.isObject()) {
      List<String> fieldNames=Lists.newArrayList(jsonNode.fieldNames());
      for (      String key : fieldNames) {
        validateConditionSectionArgTypesWherePossible(jsonNode.get(key));
      }
      for (      IntrinsicFunction intrinsicFunction : IntrinsicFunctions.values()) {
        IntrinsicFunction.MatchResult matchResult=intrinsicFunction.evaluateMatch(jsonNode);
        if (matchResult.isMatch()) {
          intrinsicFunction.validateArgTypesWherePossible(matchResult);
        }
        if (intrinsicFunction == IntrinsicFunctions.CONDITION && !inConditionsSection) {
          throw new ValidationErrorException("String_Node_Str");
        }
        if (intrinsicFunction == IntrinsicFunctions.EQUALS && !inConditionsSection) {
          throw new ValidationErrorException("String_Node_Str");
        }
      }
    }
  }
}

Fixed version (ground truth):
private static void validateArgTypesWherePossible(JsonNode jsonNode,boolean inConditionsSection) throws CloudFormationException {
  if (jsonNode != null) {
    if (jsonNode.isArray()) {
      for (int i=0; i < jsonNode.size(); i++) {
        validateConditionSectionArgTypesWherePossible(jsonNode.get(i));
      }
    }
 else     if (jsonNode.isObject()) {
      List<String> fieldNames=Lists.newArrayList(jsonNode.fieldNames());
      for (      String key : fieldNames) {
        validateConditionSectionArgTypesWherePossible(jsonNode.get(key));
      }
      for (      IntrinsicFunction intrinsicFunction : IntrinsicFunctions.values()) {
        IntrinsicFunction.MatchResult matchResult=intrinsicFunction.evaluateMatch(jsonNode);
        if (matchResult.isMatch()) {
          intrinsicFunction.validateArgTypesWherePossible(matchResult);
          if (intrinsicFunction == IntrinsicFunctions.CONDITION && !inConditionsSection) {
            throw new ValidationErrorException("String_Node_Str");
          }
          if (intrinsicFunction == IntrinsicFunctions.EQUALS && !inConditionsSection) {
            throw new ValidationErrorException("String_Node_Str");
          }
        }
      }
    }
  }
}
Program: 14247
Project: 14247
Buggy source:
static JsonNode checkDouble(JsonNode parent,String key) throws CloudFormationException {
  JsonNode jsonNode=parent.get(key);
  if (jsonNode != null && !jsonNode.isTextual()) {
    throw error(errorMsg(key,"String_Node_Str"));
  }
  try {
    Double.parseDouble(jsonNode.textValue());
  }
 catch (  NumberFormatException ex) {
    throw error(errorMsg(key,"String_Node_Str" + jsonNode.textValue() + "String_Node_Str"));
  }
  return jsonNode;
}

Fixed version (ground truth):
static JsonNode checkDouble(JsonNode parent,String key) throws CloudFormationException {
  JsonNode jsonNode=parent.get(key);
  if (jsonNode != null && !jsonNode.isTextual()) {
    throw error(errorMsg(key,"String_Node_Str"));
  }
  try {
    if (jsonNode != null) {
      Double.parseDouble(jsonNode.textValue());
    }
  }
 catch (  NumberFormatException ex) {
    throw error(errorMsg(key,"String_Node_Str" + jsonNode.textValue() + "String_Node_Str"));
  }
  return jsonNode;
}
Program: 14249
Project: 14249
Buggy source:
private void parseValidTopLevelKeys(JsonNode templateJsonNode) throws CloudFormationException {
  Set<String> tempTopLevelKeys=Sets.newHashSet((Set<String>)templateJsonNode.fieldNames());
  for (  TemplateSection section : TemplateSection.values()) {
    tempTopLevelKeys.remove(section.toString());
  }
  if (!tempTopLevelKeys.isEmpty()) {
    throw new ValidationErrorException("String_Node_Str" + tempTopLevelKeys);
  }
}

Fixed version (ground truth):
private void parseValidTopLevelKeys(JsonNode templateJsonNode) throws CloudFormationException {
  Set<String> tempTopLevelKeys=Sets.newHashSet(templateJsonNode.fieldNames());
  for (  TemplateSection section : TemplateSection.values()) {
    tempTopLevelKeys.remove(section.toString());
  }
  if (!tempTopLevelKeys.isEmpty()) {
    throw new ValidationErrorException("String_Node_Str" + tempTopLevelKeys);
  }
}
Program: 14250
Project: 14250
Buggy source:
@Override public VmType apply(String vmTypeName){
  try {
    VmType vmType=VmTypes.lookup(vmTypeName);
    if (request.getReset()) {
      PredefinedTypes defaultVmType=PredefinedTypes.valueOf(vmTypeName);
      vmType.setCpu(defaultVmType.getCpu());
      vmType.setDisk(defaultVmType.getDisk());
      vmType.setMemory(defaultVmType.getMemory());
    }
 else {
      vmType.setCpu(Objects.firstNonNull(request.getCpu(),vmType.getCpu()));
      vmType.setDisk(Objects.firstNonNull(request.getDisk(),vmType.getDisk()));
      vmType.setMemory(Objects.firstNonNull(request.getMemory(),vmType.getMemory()));
    }
    VmTypes.update(vmType);
    return vmType;
  }
 catch (  NoSuchMetadataException ex) {
    throw Exceptions.toUndeclared(ex);
  }
}

Fixed version (ground truth):
@Override public VmType apply(String vmTypeName){
  try {
    VmType vmType=VmTypes.lookup(vmTypeName);
    if (request.getReset()) {
      PredefinedTypes defaultVmType=PredefinedTypes.valueOf(vmTypeName.toUpperCase().replace("String_Node_Str","String_Node_Str"));
      vmType.setCpu(defaultVmType.getCpu());
      vmType.setDisk(defaultVmType.getDisk());
      vmType.setMemory(defaultVmType.getMemory());
    }
 else {
      vmType.setCpu(Objects.firstNonNull(request.getCpu(),vmType.getCpu()));
      vmType.setDisk(Objects.firstNonNull(request.getDisk(),vmType.getDisk()));
      vmType.setMemory(Objects.firstNonNull(request.getMemory(),vmType.getMemory()));
    }
    VmTypes.update(vmType);
    return vmType;
  }
 catch (  NoSuchMetadataException ex) {
    throw Exceptions.toUndeclared(ex);
  }
}
Program: 14252
Project: 14252
Buggy source:
private ClusterAllocator(final Allocation allocInfo){
  this.allocInfo=allocInfo;
  final EntityTransaction db=Entities.get(VmInstance.class);
  try {
    this.cluster=Clusters.lookup(Topology.lookup(ClusterController.class,allocInfo.getPartition()));
    this.messages=new StatefulMessageSet<State>(this.cluster,State.values());
    this.setupNetworkMessages();
    this.setupVolumeMessages();
    db.commit();
  }
 catch (  final Exception e) {
    db.rollback();
    cleanupOnFailure(allocInfo,e);
    return;
  }
  try {
    for (    final ResourceToken token : allocInfo.getAllocationTokens()) {
      this.setupVmMessages(token);
    }
  }
 catch (  final Exception e) {
    cleanupOnFailure(allocInfo,e);
  }
}

Fixed version (ground truth):
private ClusterAllocator(final Allocation allocInfo){
  this.allocInfo=allocInfo;
  final EntityTransaction db=Entities.get(VmInstance.class);
  try {
    this.cluster=Clusters.lookup(Topology.lookup(ClusterController.class,allocInfo.getPartition()));
    this.messages=new StatefulMessageSet<State>(this.cluster,State.values());
    this.setupNetworkMessages();
    this.setupVolumeMessages();
    this.updateResourceMessages();
    db.commit();
  }
 catch (  final Exception e) {
    db.rollback();
    cleanupOnFailure(allocInfo,e);
    return;
  }
  try {
    for (    final ResourceToken token : allocInfo.getAllocationTokens()) {
      this.setupVmMessages(token);
    }
  }
 catch (  final Exception e) {
    cleanupOnFailure(allocInfo,e);
  }
}
Program: 14255
Project: 14255
Buggy source:
@Override public void run(){
  try {
    for (    StackResourceEntity stackResourceEntity : StackResourceEntityManager.getStackResources(stack.getStackName())) {
      Resource resource=null;
      if (stackResourceEntity.getResourceType().equals("String_Node_Str")) {
        AWSEC2Instance awsec2Instance=new AWSEC2Instance();
        awsec2Instance.setOwnerUserId(userId);
        awsec2Instance.setLogicalResourceId(stackResourceEntity.getLogicalResourceId());
        awsec2Instance.setType(stackResourceEntity.getResourceType());
        awsec2Instance.setPhysicalResourceId(awsec2Instance.getPhysicalResourceId());
        resource=awsec2Instance;
      }
      try {
        resource.delete();
      }
 catch (      Exception ex) {
        LOG.error(ex,ex);
      }
    }
    StackResourceEntityManager.deleteStackResources(stack.getStackName());
    StackEventEntityManager.deleteStackEvents(stack.getStackName());
    StackEntityManager.deleteStack(stack.getStackName());
  }
 catch (  Exception ex) {
    LOG.error(ex,ex);
  }
}

Fixed version (ground truth):
@Override public void run(){
  try {
    LOG.info("String_Node_Str" + stack.getStackName());
    for (    StackResourceEntity stackResourceEntity : StackResourceEntityManager.getStackResources(stack.getStackName())) {
      Resource resource=null;
      LOG.info("String_Node_Str" + stackResourceEntity.getResourceType());
      LOG.info("String_Node_Str" + stackResourceEntity.getPhysicalResourceId());
      if (stackResourceEntity.getResourceType().equals("String_Node_Str")) {
        LOG.info("String_Node_Str");
        AWSEC2Instance awsec2Instance=new AWSEC2Instance();
        awsec2Instance.setOwnerUserId(userId);
        awsec2Instance.setLogicalResourceId(stackResourceEntity.getLogicalResourceId());
        awsec2Instance.setType(stackResourceEntity.getResourceType());
        awsec2Instance.setPhysicalResourceId(stackResourceEntity.getPhysicalResourceId());
        resource=awsec2Instance;
      }
      try {
        resource.delete();
      }
 catch (      Throwable ex) {
        LOG.error(ex,ex);
      }
    }
    StackResourceEntityManager.deleteStackResources(stack.getStackName());
    StackEventEntityManager.deleteStackEvents(stack.getStackName());
    StackEntityManager.deleteStack(stack.getStackName());
  }
 catch (  Throwable ex) {
    LOG.error(ex,ex);
  }
}
Program: 14256
Project: 14256
Buggy source:
public static void addStack(Stack stack) throws Exception {
  try (TransactionResource db=Entities.transactionFor(StackEntity.class)){
    Criteria criteria=Entities.createCriteria(StackEntity.class).add(Restrictions.or(Restrictions.eq("String_Node_Str",stack.getStackName()),Restrictions.eq("String_Node_Str",stack.getStackId())));
    List<StackEntity> EntityList=criteria.list();
    if (!EntityList.isEmpty()) {
      throw new Exception("String_Node_Str");
    }
    LOG.info("String_Node_Str" + stack.getStackName());
    StackEntity stackEntity=stackToStackEntity(stack);
    LOG.info("String_Node_Str" + stackEntity.getStackName());
    Entities.persist(stackEntity);
    db.commit();
  }
 }

Fixed version (ground truth):
public static void addStack(Stack stack) throws Exception {
  try (TransactionResource db=Entities.transactionFor(StackEntity.class)){
    Criteria criteria=Entities.createCriteria(StackEntity.class).add(Restrictions.eq("String_Node_Str",stack.getStackName()));
    List<StackEntity> EntityList=criteria.list();
    if (!EntityList.isEmpty()) {
      throw new Exception("String_Node_Str");
    }
    LOG.info("String_Node_Str" + stack.getStackName());
    StackEntity stackEntity=stackToStackEntity(stack);
    LOG.info("String_Node_Str" + stackEntity.getStackName());
    Entities.persist(stackEntity);
    db.commit();
  }
 }
Program: 14257
Project: 14257
Buggy source:
public static Stack getStack(String stackName){
  StackEntity stackEntity=null;
  try (TransactionResource db=Entities.transactionFor(StackEntity.class)){
    Criteria criteria=Entities.createCriteria(StackEntity.class).add(Restrictions.eq("String_Node_Str",stackName));
    List<StackEntity> entityList=criteria.list();
    if (entityList != null && !entityList.isEmpty()) {
      stackEntity=entityList.get(0);
    }
    db.commit();
  }
   if (stackEntity != null)   return stackEntityToStack(stackEntity);
  return null;
}

Fixed version (ground truth):
public static Stack getStack(String stackName){
  Stack stack=null;
  try (TransactionResource db=Entities.transactionFor(StackEntity.class)){
    Criteria criteria=Entities.createCriteria(StackEntity.class).add(Restrictions.eq("String_Node_Str",stackName));
    List<StackEntity> entityList=criteria.list();
    if (entityList != null && !entityList.isEmpty()) {
      stack=stackEntityToStack(entityList.get(0));
    }
    db.commit();
  }
   return stack;
}