Program: 106443
Project: 106443
Buggy source:
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) public static void setupParameters(BaseCmd cmd,Map<String,String> params,List<ControlledEntity> entitiesToAccess){
  Map<String,Object> unpackedParams=cmd.unpackParams(params);
  if (cmd instanceof BaseListCmd) {
    Object pageSizeObj=unpackedParams.get(ApiConstants.PAGE_SIZE);
    Long pageSize=null;
    if (pageSizeObj != null) {
      pageSize=Long.valueOf((String)pageSizeObj);
    }
    if ((unpackedParams.get(ApiConstants.PAGE) == null) && (pageSize != null && pageSize != BaseListCmd.PAGESIZE_UNLIMITED)) {
      ServerApiException ex=new ServerApiException(BaseCmd.PARAM_ERROR,"String_Node_Str");
      ex.setCSErrorCode(CSExceptionErrorCode.getCSErrCode(ex.getClass().getName()));
      throw ex;
    }
 else     if (pageSize == null && (unpackedParams.get(ApiConstants.PAGE) != null)) {
      throw new ServerApiException(BaseCmd.PARAM_ERROR,"String_Node_Str");
    }
  }
  Field[] fields=cmd.getClass().getDeclaredFields();
  Class<?> superClass=cmd.getClass().getSuperclass();
  while (BaseCmd.class.isAssignableFrom(superClass)) {
    Field[] superClassFields=superClass.getDeclaredFields();
    if (superClassFields != null) {
      Field[] tmpFields=new Field[fields.length + superClassFields.length];
      System.arraycopy(fields,0,tmpFields,0,fields.length);
      System.arraycopy(superClassFields,0,tmpFields,fields.length,superClassFields.length);
      fields=tmpFields;
    }
    superClass=superClass.getSuperclass();
  }
  for (  Field field : fields) {
    PlugService plugServiceAnnotation=field.getAnnotation(PlugService.class);
    if (plugServiceAnnotation != null) {
      plugService(field,cmd);
    }
    Parameter parameterAnnotation=field.getAnnotation(Parameter.class);
    if ((parameterAnnotation == null) || !parameterAnnotation.expose()) {
      continue;
    }
    IdentityMapper identityMapper=field.getAnnotation(IdentityMapper.class);
    Object paramObj=unpackedParams.get(parameterAnnotation.name());
    if (paramObj == null) {
      if (parameterAnnotation.required()) {
        throw new ServerApiException(BaseCmd.PARAM_ERROR,"String_Node_Str" + cmd.getCommandName().substring(0,cmd.getCommandName().length() - 8) + "String_Node_Str"+ parameterAnnotation.name());
      }
      continue;
    }
    try {
      setFieldValue(field,cmd,paramObj,parameterAnnotation,identityMapper);
    }
 catch (    IllegalArgumentException argEx) {
      if (s_logger.isDebugEnabled()) {
        s_logger.debug("String_Node_Str" + cmd.getCommandName() + "String_Node_Str"+ paramObj+ "String_Node_Str"+ parameterAnnotation.name());
      }
      throw new ServerApiException(BaseCmd.PARAM_ERROR,"String_Node_Str" + cmd.getCommandName().substring(0,cmd.getCommandName().length() - 8) + "String_Node_Str"+ paramObj+ "String_Node_Str"+ parameterAnnotation.name());
    }
catch (    ParseException parseEx) {
      if (s_logger.isDebugEnabled()) {
        s_logger.debug("String_Node_Str" + paramObj + "String_Node_Str"+ cmd.getCommandName().substring(0,cmd.getCommandName().length() - 8));
      }
      throw new ServerApiException(BaseCmd.PARAM_ERROR,"String_Node_Str" + paramObj + "String_Node_Str"+ cmd.getCommandName().substring(0,cmd.getCommandName().length() - 8)+ "String_Node_Str");
    }
catch (    InvalidParameterValueException invEx) {
      throw new ServerApiException(BaseCmd.PARAM_ERROR,"String_Node_Str" + cmd.getCommandName().substring(0,cmd.getCommandName().length() - 8) + "String_Node_Str"+ invEx.getMessage());
    }
catch (    CloudRuntimeException cloudEx) {
      throw new ServerApiException(BaseCmd.INTERNAL_ERROR,"String_Node_Str" + cmd.getCommandName().substring(0,cmd.getCommandName().length() - 8));
    }
    try {
      ACL checkAccess=field.getAnnotation(ACL.class);
      CommandType fieldType=parameterAnnotation.type();
      if (checkAccess != null) {
        if (parameterAnnotation.resourceType() != null) {
          Class<?>[] entity=parameterAnnotation.resourceType();
          if (ControlledEntity.class.isAssignableFrom(entity)) {
            if (s_logger.isDebugEnabled()) {
              s_logger.debug("String_Node_Str" + entity.getName());
            }
            if (s_instance._daoNameMap.containsKey(entity.getName())) {
              Class<? extends GenericDao> daoClass=s_instance._daoNameMap.get(entity.getName());
              GenericDao daoClassInstance=s_instance._locator.getDao(daoClass);
switch (fieldType) {
case LIST:
                CommandType listType=parameterAnnotation.collectionType();
switch (listType) {
case LONG:
                List<Long> listParam=new ArrayList<Long>();
              listParam=(List)field.get(cmd);
            for (            Long entityId : listParam) {
              ControlledEntity entityObj=(ControlledEntity)daoClassInstance.findById(entityId);
              entitiesToAccess.add(entityObj);
            }
          break;
default :
        break;
    }
  break;
case LONG:
Long entityId=(Long)field.get(cmd);
ControlledEntity entityObj=(ControlledEntity)daoClassInstance.findById(entityId);
entitiesToAccess.add(entityObj);
break;
default :
break;
}
}
}
}
}
}
 catch (IllegalArgumentException e) {
s_logger.error("String_Node_Str" + cmd.getCommandName() + "String_Node_Str"+ field.getName()+ "String_Node_Str");
throw new CloudRuntimeException("String_Node_Str" + cmd.getCommandName() + "String_Node_Str"+ field.getName()+ "String_Node_Str");
}
catch (IllegalAccessException e) {
s_logger.error("String_Node_Str" + cmd.getCommandName() + "String_Node_Str"+ field.getName()+ "String_Node_Str");
throw new CloudRuntimeException("String_Node_Str" + cmd.getCommandName() + "String_Node_Str"+ field.getName()+ "String_Node_Str");
}
}
}

Fixed version (ground truth):
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) public static void setupParameters(BaseCmd cmd,Map<String,String> params,List<ControlledEntity> entitiesToAccess){
  Map<String,Object> unpackedParams=cmd.unpackParams(params);
  if (cmd instanceof BaseListCmd) {
    Object pageSizeObj=unpackedParams.get(ApiConstants.PAGE_SIZE);
    Long pageSize=null;
    if (pageSizeObj != null) {
      pageSize=Long.valueOf((String)pageSizeObj);
    }
    if ((unpackedParams.get(ApiConstants.PAGE) == null) && (pageSize != null && pageSize != BaseListCmd.PAGESIZE_UNLIMITED)) {
      ServerApiException ex=new ServerApiException(BaseCmd.PARAM_ERROR,"String_Node_Str");
      ex.setCSErrorCode(CSExceptionErrorCode.getCSErrCode(ex.getClass().getName()));
      throw ex;
    }
 else     if (pageSize == null && (unpackedParams.get(ApiConstants.PAGE) != null)) {
      throw new ServerApiException(BaseCmd.PARAM_ERROR,"String_Node_Str");
    }
  }
  Field[] fields=cmd.getClass().getDeclaredFields();
  Class<?> superClass=cmd.getClass().getSuperclass();
  while (BaseCmd.class.isAssignableFrom(superClass)) {
    Field[] superClassFields=superClass.getDeclaredFields();
    if (superClassFields != null) {
      Field[] tmpFields=new Field[fields.length + superClassFields.length];
      System.arraycopy(fields,0,tmpFields,0,fields.length);
      System.arraycopy(superClassFields,0,tmpFields,fields.length,superClassFields.length);
      fields=tmpFields;
    }
    superClass=superClass.getSuperclass();
  }
  for (  Field field : fields) {
    PlugService plugServiceAnnotation=field.getAnnotation(PlugService.class);
    if (plugServiceAnnotation != null) {
      plugService(field,cmd);
    }
    Parameter parameterAnnotation=field.getAnnotation(Parameter.class);
    if ((parameterAnnotation == null) || !parameterAnnotation.expose()) {
      continue;
    }
    IdentityMapper identityMapper=field.getAnnotation(IdentityMapper.class);
    Object paramObj=unpackedParams.get(parameterAnnotation.name());
    if (paramObj == null) {
      if (parameterAnnotation.required()) {
        throw new ServerApiException(BaseCmd.PARAM_ERROR,"String_Node_Str" + cmd.getCommandName().substring(0,cmd.getCommandName().length() - 8) + "String_Node_Str"+ parameterAnnotation.name());
      }
      continue;
    }
    try {
      setFieldValue(field,cmd,paramObj,parameterAnnotation,identityMapper);
    }
 catch (    IllegalArgumentException argEx) {
      if (s_logger.isDebugEnabled()) {
        s_logger.debug("String_Node_Str" + cmd.getCommandName() + "String_Node_Str"+ paramObj+ "String_Node_Str"+ parameterAnnotation.name());
      }
      throw new ServerApiException(BaseCmd.PARAM_ERROR,"String_Node_Str" + cmd.getCommandName().substring(0,cmd.getCommandName().length() - 8) + "String_Node_Str"+ paramObj+ "String_Node_Str"+ parameterAnnotation.name());
    }
catch (    ParseException parseEx) {
      if (s_logger.isDebugEnabled()) {
        s_logger.debug("String_Node_Str" + paramObj + "String_Node_Str"+ cmd.getCommandName().substring(0,cmd.getCommandName().length() - 8));
      }
      throw new ServerApiException(BaseCmd.PARAM_ERROR,"String_Node_Str" + paramObj + "String_Node_Str"+ cmd.getCommandName().substring(0,cmd.getCommandName().length() - 8)+ "String_Node_Str");
    }
catch (    InvalidParameterValueException invEx) {
      throw new ServerApiException(BaseCmd.PARAM_ERROR,"String_Node_Str" + cmd.getCommandName().substring(0,cmd.getCommandName().length() - 8) + "String_Node_Str"+ invEx.getMessage());
    }
catch (    CloudRuntimeException cloudEx) {
      throw new ServerApiException(BaseCmd.INTERNAL_ERROR,"String_Node_Str" + cmd.getCommandName().substring(0,cmd.getCommandName().length() - 8));
    }
    try {
      ACL checkAccess=field.getAnnotation(ACL.class);
      CommandType fieldType=parameterAnnotation.type();
      if (checkAccess != null) {
        if (parameterAnnotation.resourceType() != null) {
          Class<?>[] entityList=parameterAnnotation.resourceType();
          for (          Class entity : entityList) {
            if (ControlledEntity.class.isAssignableFrom(entity)) {
              if (s_logger.isDebugEnabled()) {
                s_logger.debug("String_Node_Str" + entity.getName());
              }
              if (s_instance._daoNameMap.containsKey(entity.getName())) {
                Class<? extends GenericDao> daoClass=s_instance._daoNameMap.get(entity.getName());
                GenericDao daoClassInstance=s_instance._locator.getDao(daoClass);
switch (fieldType) {
case LIST:
                  CommandType listType=parameterAnnotation.collectionType();
switch (listType) {
case LONG:
                  List<Long> listParam=new ArrayList<Long>();
                listParam=(List)field.get(cmd);
              for (              Long entityId : listParam) {
                ControlledEntity entityObj=(ControlledEntity)daoClassInstance.findById(entityId);
                entitiesToAccess.add(entityObj);
              }
            break;
default :
          break;
      }
    break;
case LONG:
  Long entityId=(Long)field.get(cmd);
ControlledEntity entityObj=(ControlledEntity)daoClassInstance.findById(entityId);
entitiesToAccess.add(entityObj);
break;
default :
break;
}
}
}
}
}
}
}
 catch (IllegalArgumentException e) {
s_logger.error("String_Node_Str" + cmd.getCommandName() + "String_Node_Str"+ field.getName()+ "String_Node_Str");
throw new CloudRuntimeException("String_Node_Str" + cmd.getCommandName() + "String_Node_Str"+ field.getName()+ "String_Node_Str");
}
catch (IllegalAccessException e) {
s_logger.error("String_Node_Str" + cmd.getCommandName() + "String_Node_Str"+ field.getName()+ "String_Node_Str");
throw new CloudRuntimeException("String_Node_Str" + cmd.getCommandName() + "String_Node_Str"+ field.getName()+ "String_Node_Str");
}
}
}