[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