Program: 166407
Project: 166407
Buggy source:
private RangerPolicy mapXResourceToPolicy(RangerPolicy policy,XXResource xRes,RangerService service){
  String serviceName=service.getName();
  String serviceDef=service.getType();
  String name=xRes.getPolicyName();
  String description=xRes.getDescription();
  Boolean isAuditEnabled=true;
  Boolean isEnabled=true;
  Map<String,RangerPolicyResource> resources=new HashMap<String,RangerPolicyResource>();
  List<RangerPolicyItem> policyItems=new ArrayList<RangerPolicyItem>();
  List<XXAuditMap> auditMapList=daoMgr.getXXAuditMap().findByResourceId(xRes.getId());
  if (stringUtil.isEmpty(auditMapList)) {
    isAuditEnabled=false;
  }
  if (xRes.getResourceStatus() == AppConstants.STATUS_DISABLED) {
    isEnabled=false;
  }
  boolean tableExcludes=false;
  boolean columnExcludes=false;
  if (xRes.getTableType() == AppConstants.POLICY_EXCLUSION) {
    tableExcludes=true;
  }
  if (xRes.getColumnType() == AppConstants.POLICY_EXCLUSION) {
    columnExcludes=true;
  }
  if (serviceDef.equalsIgnoreCase("String_Node_Str")) {
    resources.put("String_Node_Str",new RangerPolicyResource(Arrays.asList(xRes.getName()),false,AppConstants.getBooleanFor_BooleanValue(xRes.getIsRecursive())));
  }
 else   if (serviceDef.equalsIgnoreCase("String_Node_Str")) {
    resources.put("String_Node_Str",new RangerPolicyResource(Arrays.asList(xRes.getTables()),tableExcludes,false));
    resources.put("String_Node_Str",new RangerPolicyResource(Arrays.asList(xRes.getColumns()),columnExcludes,false));
    resources.put("String_Node_Str",new RangerPolicyResource(Arrays.asList(xRes.getColumnFamilies()),false,false));
  }
 else   if (serviceDef.equalsIgnoreCase("String_Node_Str")) {
    resources.put("String_Node_Str",new RangerPolicyResource(Arrays.asList(xRes.getTables()),tableExcludes,false));
    resources.put("String_Node_Str",new RangerPolicyResource(Arrays.asList(xRes.getColumns()),columnExcludes,false));
    resources.put("String_Node_Str",new RangerPolicyResource(Arrays.asList(xRes.getDatabases()),false,false));
    resources.put("String_Node_Str",new RangerPolicyResource(Arrays.asList(xRes.getUdfs()),false,false));
  }
 else   if (serviceDef.equalsIgnoreCase("String_Node_Str")) {
    resources.put("String_Node_Str",new RangerPolicyResource(Arrays.asList(xRes.getTopologies()),false,false));
    resources.put("String_Node_Str",new RangerPolicyResource(Arrays.asList(xRes.getServices()),false,false));
  }
 else   if (serviceDef.equalsIgnoreCase("String_Node_Str")) {
    resources.put("String_Node_Str",new RangerPolicyResource(Arrays.asList(xRes.getTopologies()),false,false));
  }
  policyItems=getPolicyItemListForRes(xRes,serviceDef);
  policy.setService(serviceName);
  policy.setName(name);
  policy.setDescription(description);
  policy.setIsAuditEnabled(isAuditEnabled);
  policy.setIsEnabled(isEnabled);
  policy.setResources(resources);
  policy.setPolicyItems(policyItems);
  policy.setCreateTime(xRes.getCreateTime());
  policy.setUpdateTime(xRes.getUpdateTime());
  XXPortalUser createdByUser=daoMgr.getXXPortalUser().getById(xRes.getAddedByUserId());
  XXPortalUser updByUser=daoMgr.getXXPortalUser().getById(xRes.getUpdatedByUserId());
  if (createdByUser != null) {
    policy.setCreatedBy(createdByUser.getLoginId());
  }
  if (updByUser != null) {
    policy.setUpdatedBy(updByUser.getLoginId());
  }
  policy.setId(xRes.getId());
  return policy;
}

Fixed version (ground truth):
private RangerPolicy mapXResourceToPolicy(RangerPolicy policy,XXResource xRes,RangerService service){
  String serviceName=service.getName();
  String serviceType=service.getType();
  String name=xRes.getPolicyName();
  String description=xRes.getDescription();
  Boolean isAuditEnabled=true;
  Boolean isEnabled=true;
  Map<String,RangerPolicyResource> resources=new HashMap<String,RangerPolicyResource>();
  List<RangerPolicyItem> policyItems=new ArrayList<RangerPolicyItem>();
  XXServiceDef svcDef=daoMgr.getXXServiceDef().findByName(serviceType);
  if (svcDef == null) {
    logger.error(serviceType + "String_Node_Str" + name+ "String_Node_Str");
    return null;
  }
  List<XXAuditMap> auditMapList=daoMgr.getXXAuditMap().findByResourceId(xRes.getId());
  if (stringUtil.isEmpty(auditMapList)) {
    isAuditEnabled=false;
  }
  if (xRes.getResourceStatus() == AppConstants.STATUS_DISABLED) {
    isEnabled=false;
  }
  Boolean isPathRecursive=xRes.getIsRecursive() == RangerCommonEnums.BOOL_TRUE;
  Boolean isTableExcludes=xRes.getTableType() == RangerCommonEnums.POLICY_EXCLUSION;
  Boolean isColumnExcludes=xRes.getColumnType() == RangerCommonEnums.POLICY_EXCLUSION;
  if (StringUtils.equalsIgnoreCase(serviceType,"String_Node_Str")) {
    toRangerResourceList(xRes.getName(),"String_Node_Str",Boolean.FALSE,isPathRecursive,resources);
  }
 else   if (StringUtils.equalsIgnoreCase(serviceType,"String_Node_Str")) {
    toRangerResourceList(xRes.getTables(),"String_Node_Str",isTableExcludes,Boolean.FALSE,resources);
    toRangerResourceList(xRes.getColumnFamilies(),"String_Node_Str",Boolean.FALSE,Boolean.FALSE,resources);
    toRangerResourceList(xRes.getColumns(),"String_Node_Str",isColumnExcludes,Boolean.FALSE,resources);
  }
 else   if (StringUtils.equalsIgnoreCase(serviceType,"String_Node_Str")) {
    toRangerResourceList(xRes.getDatabases(),"String_Node_Str",Boolean.FALSE,Boolean.FALSE,resources);
    toRangerResourceList(xRes.getTables(),"String_Node_Str",isTableExcludes,Boolean.FALSE,resources);
    toRangerResourceList(xRes.getColumns(),"String_Node_Str",isColumnExcludes,Boolean.FALSE,resources);
    toRangerResourceList(xRes.getUdfs(),"String_Node_Str",Boolean.FALSE,Boolean.FALSE,resources);
  }
 else   if (StringUtils.equalsIgnoreCase(serviceType,"String_Node_Str")) {
    toRangerResourceList(xRes.getTopologies(),"String_Node_Str",Boolean.FALSE,Boolean.FALSE,resources);
    toRangerResourceList(xRes.getServices(),"String_Node_Str",Boolean.FALSE,Boolean.FALSE,resources);
  }
 else   if (StringUtils.equalsIgnoreCase(serviceType,"String_Node_Str")) {
    toRangerResourceList(xRes.getTopologies(),"String_Node_Str",Boolean.FALSE,Boolean.FALSE,resources);
  }
  policyItems=getPolicyItemListForRes(xRes,svcDef);
  policy.setService(serviceName);
  policy.setName(name);
  policy.setDescription(description);
  policy.setIsAuditEnabled(isAuditEnabled);
  policy.setIsEnabled(isEnabled);
  policy.setResources(resources);
  policy.setPolicyItems(policyItems);
  policy.setCreateTime(xRes.getCreateTime());
  policy.setUpdateTime(xRes.getUpdateTime());
  XXPortalUser createdByUser=daoMgr.getXXPortalUser().getById(xRes.getAddedByUserId());
  XXPortalUser updByUser=daoMgr.getXXPortalUser().getById(xRes.getUpdatedByUserId());
  if (createdByUser != null) {
    policy.setCreatedBy(createdByUser.getLoginId());
  }
  if (updByUser != null) {
    policy.setUpdatedBy(updByUser.getLoginId());
  }
  policy.setId(xRes.getId());
  return policy;
}