[ 
https://issues.apache.org/jira/browse/OLINGO-410?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14117101#comment-14117101
 ] 

Michael Bolz commented on OLINGO-410:
-------------------------------------

Hello [~atheohar],

for OData Version 2 it is not specified that the *Function Import Parameters* 
must be ordered.
As example for the according 
[URI|http://www.odata.org/documentation/odata-version-2-0/uri-conventions#AddressingServiceOperations]
 it is specified as *insignificant*.

bq. ParamName: The name of a parameter accepted by the Service Operation. If 
the Service Operation accepts multiple parameters, the order of the parameters 
in the query string of the URI is insignificant.

But also I think your suggestion for change the {{getParameterNames()}} is 
reasonable.
So I changed it and pushed it into [this 
branch|https://git-wip-us.apache.org/repos/asf?p=olingo-odata2.git;a=shortlog;h=refs/heads/OLINGO-410_SortedFunctionImportParameterNames].
Can you please give feedback if it works for you before I push it into the 
master branch.

Thanks and kind regards,
Michael


> Function invocation with parameters using reflection fails due to reordering 
> of the parameter list when parsing the metadata
> ----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: OLINGO-410
>                 URL: https://issues.apache.org/jira/browse/OLINGO-410
>             Project: Olingo
>          Issue Type: Bug
>          Components: odata2-core
>    Affects Versions: V2 2.0.0
>            Reporter: Antonis Theocharides
>            Assignee: Michael Bolz
>
> 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;
>   }



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to