Program: 166397
Project: 166397
Buggy source:
@Override public RangerService createService(RangerService service) throws Exception {
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str" + service + "String_Node_Str");
  }
  if (service == null) {
    throw restErrorUtil.createRESTException("String_Node_Str",MessageEnums.ERROR_CREATING_OBJECT);
  }
  boolean createDefaultPolicy=true;
  Map<String,String> configs=service.getConfigs();
  Map<String,String> validConfigs=validateRequiredConfigParams(service,configs);
  if (validConfigs == null) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("String_Node_Str" + service + "String_Node_Str");
    }
    throw restErrorUtil.createRESTException("String_Node_Str",MessageEnums.ERROR_CREATING_OBJECT);
  }
  service.setVersion(new Long(1));
  if (populateExistingBaseFields) {
    svcServiceWithAssignedId.setPopulateExistingBaseFields(true);
    daoMgr.getXXService().setIdentityInsert(true);
    service=svcServiceWithAssignedId.create(service);
    daoMgr.getXXService().setIdentityInsert(false);
    daoMgr.getXXService().updateSequence();
    svcServiceWithAssignedId.setPopulateExistingBaseFields(false);
    createDefaultPolicy=false;
  }
 else {
    service=svcService.create(service);
  }
  XXService xCreatedService=daoMgr.getXXService().getById(service.getId());
  VXUser vXUser=null;
  XXServiceConfigMapDao xConfMapDao=daoMgr.getXXServiceConfigMap();
  for (  Entry<String,String> configMap : validConfigs.entrySet()) {
    String configKey=configMap.getKey();
    String configValue=configMap.getValue();
    if (StringUtils.equalsIgnoreCase(configKey,"String_Node_Str")) {
      String userName=stringUtil.getValidUserName(configValue);
      XXUser xxUser=daoMgr.getXXUser().findByUserName(userName);
      if (xxUser != null) {
        vXUser=xUserService.populateViewBean(xxUser);
      }
 else {
        vXUser=new VXUser();
        vXUser.setName(userName);
        vXUser.setUserSource(RangerCommonEnums.USER_EXTERNAL);
        UserSessionBase usb=ContextUtil.getCurrentUserSession();
        if (usb != null && !usb.isUserAdmin()) {
          throw restErrorUtil.createRESTException("String_Node_Str" + userName + "String_Node_Str",MessageEnums.OPER_NO_PERMISSION);
        }
        vXUser=xUserMgr.createXUser(vXUser);
      }
    }
    if (StringUtils.equalsIgnoreCase(configKey,CONFIG_KEY_PASSWORD)) {
      String encryptedPwd=PasswordUtils.encryptPassword(configValue);
      String decryptedPwd=PasswordUtils.decryptPassword(encryptedPwd);
      if (StringUtils.equals(decryptedPwd,configValue)) {
        configValue=encryptedPwd;
      }
    }
    XXServiceConfigMap xConfMap=new XXServiceConfigMap();
    xConfMap=(XXServiceConfigMap)rangerAuditFields.populateAuditFields(xConfMap,xCreatedService);
    xConfMap.setServiceId(xCreatedService.getId());
    xConfMap.setConfigkey(configKey);
    xConfMap.setConfigvalue(configValue);
    xConfMap=xConfMapDao.create(xConfMap);
  }
  RangerService createdService=svcService.getPopulatedViewObject(xCreatedService);
  if (createdService == null) {
    throw restErrorUtil.createRESTException("String_Node_Str",MessageEnums.ERROR_CREATING_OBJECT);
  }
  dataHistService.createObjectDataHistory(createdService,RangerDataHistService.ACTION_CREATE);
  List<XXTrxLog> trxLogList=svcService.getTransactionLog(createdService,RangerServiceService.OPERATION_CREATE_CONTEXT);
  bizUtil.createTrxLog(trxLogList);
  if (createDefaultPolicy) {
    createDefaultPolicies(xCreatedService,vXUser);
  }
  return createdService;
}

Fixed version (ground truth):
@Override public RangerService createService(RangerService service) throws Exception {
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str" + service + "String_Node_Str");
  }
  if (service == null) {
    throw restErrorUtil.createRESTException("String_Node_Str",MessageEnums.ERROR_CREATING_OBJECT);
  }
  boolean createDefaultPolicy=true;
  Map<String,String> configs=service.getConfigs();
  Map<String,String> validConfigs=validateRequiredConfigParams(service,configs);
  if (validConfigs == null) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("String_Node_Str" + service + "String_Node_Str");
    }
    throw restErrorUtil.createRESTException("String_Node_Str",MessageEnums.ERROR_CREATING_OBJECT);
  }
  service.setVersion(new Long(1));
  service.setTagVersion(new Long(1));
  if (populateExistingBaseFields) {
    svcServiceWithAssignedId.setPopulateExistingBaseFields(true);
    daoMgr.getXXService().setIdentityInsert(true);
    service=svcServiceWithAssignedId.create(service);
    daoMgr.getXXService().setIdentityInsert(false);
    daoMgr.getXXService().updateSequence();
    svcServiceWithAssignedId.setPopulateExistingBaseFields(false);
    createDefaultPolicy=false;
  }
 else {
    service=svcService.create(service);
  }
  XXService xCreatedService=daoMgr.getXXService().getById(service.getId());
  VXUser vXUser=null;
  XXServiceConfigMapDao xConfMapDao=daoMgr.getXXServiceConfigMap();
  for (  Entry<String,String> configMap : validConfigs.entrySet()) {
    String configKey=configMap.getKey();
    String configValue=configMap.getValue();
    if (StringUtils.equalsIgnoreCase(configKey,"String_Node_Str")) {
      String userName=stringUtil.getValidUserName(configValue);
      XXUser xxUser=daoMgr.getXXUser().findByUserName(userName);
      if (xxUser != null) {
        vXUser=xUserService.populateViewBean(xxUser);
      }
 else {
        vXUser=new VXUser();
        vXUser.setName(userName);
        vXUser.setUserSource(RangerCommonEnums.USER_EXTERNAL);
        UserSessionBase usb=ContextUtil.getCurrentUserSession();
        if (usb != null && !usb.isUserAdmin()) {
          throw restErrorUtil.createRESTException("String_Node_Str" + userName + "String_Node_Str",MessageEnums.OPER_NO_PERMISSION);
        }
        vXUser=xUserMgr.createXUser(vXUser);
      }
    }
    if (StringUtils.equalsIgnoreCase(configKey,CONFIG_KEY_PASSWORD)) {
      String encryptedPwd=PasswordUtils.encryptPassword(configValue);
      String decryptedPwd=PasswordUtils.decryptPassword(encryptedPwd);
      if (StringUtils.equals(decryptedPwd,configValue)) {
        configValue=encryptedPwd;
      }
    }
    XXServiceConfigMap xConfMap=new XXServiceConfigMap();
    xConfMap=(XXServiceConfigMap)rangerAuditFields.populateAuditFields(xConfMap,xCreatedService);
    xConfMap.setServiceId(xCreatedService.getId());
    xConfMap.setConfigkey(configKey);
    xConfMap.setConfigvalue(configValue);
    xConfMap=xConfMapDao.create(xConfMap);
  }
  RangerService createdService=svcService.getPopulatedViewObject(xCreatedService);
  if (createdService == null) {
    throw restErrorUtil.createRESTException("String_Node_Str",MessageEnums.ERROR_CREATING_OBJECT);
  }
  dataHistService.createObjectDataHistory(createdService,RangerDataHistService.ACTION_CREATE);
  List<XXTrxLog> trxLogList=svcService.getTransactionLog(createdService,RangerServiceService.OPERATION_CREATE_CONTEXT);
  bizUtil.createTrxLog(trxLogList);
  if (createDefaultPolicy) {
    createDefaultPolicies(xCreatedService,vXUser);
  }
  return createdService;
}