Uploaded image for project: 'Olingo'
  1. Olingo
  2. OLINGO-410

Function invocation with parameters using reflection fails due to reordering of the parameter list when parsing the metadata

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • V2 2.0.0
    • V2 2.0.1
    • odata2-core
    • None

    Description

      In order to call a function import method, reflection is used by getting the parameter list from the metadata and calling the Class.getMethod(String name, Class<?>... parameterTypes).
      The problem occurs in EdmFunctionImportImplProv. buildFunctionImportParametersInternal method where a hashtable is used to temporarily store the parameter list and then retrieve them from the EdmFunctionImportImplProv.getParameterNames function. Using a hashtable to store them means that depending on the name of the parameter their order might change when retrieved by an iterator. In result. When getParameterNames is called and passed into the Class.getMethod method if the order of the parameters is wrong an exception is thrown because the signature we are looking for does not exist.
      Proposed solution might be
      @Override
      public List<String> getParameterNames() throws EdmException {
      if (parametersList == null) {
      parametersList = new ArrayList<String>();

      if(functionImport.getParameters() != null){
      for (FunctionImportParameter functionImportParameter : functionImport.getParameters())

      { parametersList.add(functionImportParameter.getName()); }

      }
      }

      return parametersList;
      }

      Attachments

        Activity

          People

            mirbo mibo
            atheohar Antonis Theocharides
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: