Program: 14254
Project: 14254
Buggy source:
@Override public void run(){
  try {
    for (    Resource resource : template.getResourceList()) {
      new TemplateParser().reevaluateResources(template);
      StackEvent stackEvent=new StackEvent();
      stackEvent.setStackId(stack.getStackId());
      stackEvent.setStackName(stack.getStackName());
      stackEvent.setLogicalResourceId(resource.getLogicalResourceId());
      stackEvent.setPhysicalResourceId(resource.getPhysicalResourceId());
      stackEvent.setEventId(UUID.randomUUID().toString());
      stackEvent.setResourceProperties(resource.getPropertiesJSON().toString());
      stackEvent.setResourceType(resource.getType());
      stackEvent.setResourceStatus(StackResourceEntity.Status.CREATE_IN_PROGRESS.toString());
      stackEvent.setResourceStatusReason("String_Node_Str");
      stackEvent.setTimestamp(new Date());
      StackEventEntityManager.addStackEvent(stackEvent);
      StackResource stackResource=new StackResource();
      stackResource.setResourceStatus(StackResourceEntity.Status.CREATE_IN_PROGRESS.toString());
      stackResource.setPhysicalResourceId(resource.getPhysicalResourceId());
      stackResource.setLogicalResourceId(resource.getLogicalResourceId());
      stackResource.setDescription("String_Node_Str");
      stackResource.setResourceStatusReason("String_Node_Str");
      stackResource.setResourceType(resource.getType());
      stackResource.setStackName(stack.getStackName());
      stackResource.setStackId(stack.getStackId());
      StackResourceEntityManager.addStackResource(stackResource,resource.getMetadataJSON());
      try {
        resource.create();
        StackResourceEntityManager.updatePhysicalResourceId(stack.getStackName(),resource.getLogicalResourceId(),resource.getPhysicalResourceId());
        StackResourceEntityManager.updateStatus(stack.getStackName(),resource.getLogicalResourceId(),StackResourceEntity.Status.CREATE_COMPLETE,"String_Node_Str");
        stackEvent.setEventId(UUID.randomUUID().toString());
        stackEvent.setResourceStatus(StackResourceEntity.Status.CREATE_COMPLETE.toString());
        stackEvent.setResourceStatusReason("String_Node_Str");
        stackEvent.setPhysicalResourceId(resource.getPhysicalResourceId());
        stackEvent.setTimestamp(new Date());
        StackEventEntityManager.addStackEvent(stackEvent);
        template.getReferenceMap().get(resource.getPhysicalResourceId()).setReady(true);
        template.getReferenceMap().get(resource.getPhysicalResourceId()).setReferenceValue(resource.referenceValue());
      }
 catch (      Exception ex) {
        LOG.error(ex,ex);
        StackResourceEntityManager.updateStatus(stack.getStackName(),resource.getLogicalResourceId(),StackResourceEntity.Status.CREATE_FAILED,"String_Node_Str" + ex.getMessage());
        stackEvent.setEventId(UUID.randomUUID().toString());
        stackEvent.setResourceStatus(StackResourceEntity.Status.CREATE_FAILED.toString());
        stackEvent.setTimestamp(new Date());
        stackEvent.setResourceStatusReason("String_Node_Str" + ex.getMessage());
        stackEvent.setPhysicalResourceId(resource.getPhysicalResourceId());
        StackEventEntityManager.addStackEvent(stackEvent);
        throw ex;
      }
    }
    StackEntityManager.updateStatus(stack.getStackName(),StackEntity.Status.CREATE_COMPLETE,"String_Node_Str");
  }
 catch (  Exception ex2) {
    LOG.error(ex2,ex2);
    StackEntityManager.updateStatus(stack.getStackName(),StackEntity.Status.CREATE_FAILED,ex2.getMessage());
  }
}

Fixed version (ground truth):
@Override public void run(){
  try {
    for (    Resource resource : template.getResourceList()) {
      new TemplateParser().reevaluateResources(template);
      StackEvent stackEvent=new StackEvent();
      stackEvent.setStackId(stack.getStackId());
      stackEvent.setStackName(stack.getStackName());
      stackEvent.setLogicalResourceId(resource.getLogicalResourceId());
      stackEvent.setPhysicalResourceId(resource.getPhysicalResourceId());
      stackEvent.setEventId(UUID.randomUUID().toString());
      stackEvent.setResourceProperties(resource.getPropertiesJSON().toString());
      stackEvent.setResourceType(resource.getType());
      stackEvent.setResourceStatus(StackResourceEntity.Status.CREATE_IN_PROGRESS.toString());
      stackEvent.setResourceStatusReason("String_Node_Str");
      stackEvent.setTimestamp(new Date());
      StackEventEntityManager.addStackEvent(stackEvent);
      StackResource stackResource=new StackResource();
      stackResource.setResourceStatus(StackResourceEntity.Status.CREATE_IN_PROGRESS.toString());
      stackResource.setPhysicalResourceId(resource.getPhysicalResourceId());
      stackResource.setLogicalResourceId(resource.getLogicalResourceId());
      stackResource.setDescription("String_Node_Str");
      stackResource.setResourceStatusReason("String_Node_Str");
      stackResource.setResourceType(resource.getType());
      stackResource.setStackName(stack.getStackName());
      stackResource.setStackId(stack.getStackId());
      StackResourceEntityManager.addStackResource(stackResource,resource.getMetadataJSON());
      try {
        resource.create();
        StackResourceEntityManager.updatePhysicalResourceId(stack.getStackName(),resource.getLogicalResourceId(),resource.getPhysicalResourceId());
        StackResourceEntityManager.updateStatus(stack.getStackName(),resource.getLogicalResourceId(),StackResourceEntity.Status.CREATE_COMPLETE,"String_Node_Str");
        stackEvent.setEventId(UUID.randomUUID().toString());
        stackEvent.setResourceStatus(StackResourceEntity.Status.CREATE_COMPLETE.toString());
        stackEvent.setResourceStatusReason("String_Node_Str");
        stackEvent.setPhysicalResourceId(resource.getPhysicalResourceId());
        stackEvent.setTimestamp(new Date());
        StackEventEntityManager.addStackEvent(stackEvent);
        template.getReferenceMap().get(resource.getLogicalResourceId()).setReady(true);
        template.getReferenceMap().get(resource.getLogicalResourceId()).setReferenceValue(resource.referenceValue());
      }
 catch (      Exception ex) {
        LOG.error(ex,ex);
        StackResourceEntityManager.updateStatus(stack.getStackName(),resource.getLogicalResourceId(),StackResourceEntity.Status.CREATE_FAILED,"String_Node_Str" + ex.getMessage());
        stackEvent.setEventId(UUID.randomUUID().toString());
        stackEvent.setResourceStatus(StackResourceEntity.Status.CREATE_FAILED.toString());
        stackEvent.setTimestamp(new Date());
        stackEvent.setResourceStatusReason("String_Node_Str" + ex.getMessage());
        stackEvent.setPhysicalResourceId(resource.getPhysicalResourceId());
        StackEventEntityManager.addStackEvent(stackEvent);
        throw ex;
      }
    }
    StackEntityManager.updateStatus(stack.getStackName(),StackEntity.Status.CREATE_COMPLETE,"String_Node_Str");
  }
 catch (  Exception ex2) {
    LOG.error(ex2,ex2);
    StackEntityManager.updateStatus(stack.getStackName(),StackEntity.Status.CREATE_FAILED,ex2.getMessage());
  }
}