Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ecf-dev] Remote callable parameter order not preserved

The problem is in RemoteCallParameter.Builder:

public static class Builder {
private final Map<String, Object> nameDefaultValueMap;

public Builder() {
this.nameDefaultValueMap = new HashMap<String, Object>();
}

public Builder addParameter(String name, Object defaultValue) {
this.nameDefaultValueMap.put(name, defaultValue);
return this;
}

The HashMap does not guarantee to preserve order, and the parameter order is lost. Workaround is to assemble the params array without RemoteCallParameter.Builder.

Best,
 Marin

2015-10-10 2:38 GMT+02:00 Marin Orlić <marin.orlic@xxxxxxxxx>:
Hi,

should the order of the method parameters in the service interface correspond to the order of the parameters as they are defined for the remote callable?

I have a method with the signature.

createProject(String project_name, Collection<String> project_requirements, String language, String annotation_format)

The corresponding remote callable is built with:

RemoteCallParameter.Builder parameterBuilder = new RemoteCallParameter.Builder()
            .addParameter("project_name")
            .addParameter("project_requirements")
            .addParameter("language")
            .addParameter("annotation_format");
        
RemoteCallable.Builder callableBuilder = new RemoteCallable.Builder("createProject", "/server/project")
            .setDefaultParameters(parameterBuilder.build())
            .setRequestType(new HttpPostRequestType(HttpPostRequestType.STRING_REQUEST_ENTITY, "application/json"));
        
callableBuilder.build();

Due to the HashMap in defaultParameters, there is a mismatch in the ordering of default params and the actual params. This one maintains the order:

RemoteCallParameter.Builder()
            .addParameter("phrase")
            .addParameter("language")
            .addParameter("annotation_format");
   
But this one does not:

RemoteCallParameter.Builder parameterBuilder = new RemoteCallParameter.Builder()
            .addParameter("project_name")
            .addParameter("project_requirements")
            .addParameter("language")
            .addParameter("annotation_format");

Is my assumption that the order should match correct? It seems to be assumed in AbstractClientContainer.prepareParameters().

Thanks,
 Marin

Eclipse Luna SR2
ECF 3.9.2


Back to the top