You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Randy Abernethy (JIRA)" <ji...@apache.org> on 2013/08/07 05:50:48 UTC

[jira] [Comment Edited] (THRIFT-2115) Use LinkedHashSet instead of HashSet in generated java rpc code

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

Randy Abernethy edited comment on THRIFT-2115 at 8/7/13 3:50 AM:
-----------------------------------------------------------------

Hello Jeff: 

I agree with the undercurrent here, which is reordering the set could be surprising to the user. However the definitive set is a thing without order. Depending on set order across languages gets tricky.

You are probably familiar with the Java sorted containers option provided by the compiler:
$ thrift -gen java:sorted_containers my.thrift

C++ has a similar-but-different feature allowing the exact implementation container to be specified but within the IDL using the cpp_type keyword. I think both of these features would be better off if replaced by language specific annotations in the IDL. This would make the approach consistent across languages (using annotations), get rid of the odd ball C++ only keyword and open up the Java solution (not to mention other languages) to using any container you like (be it TreeSet, LinkedHashSet or HashSet).
                
      was (Author: codesf):
    Hello Jeff: 

I agree with the undercurrent here, which is reordering the set could be surprising to the user. However the definitive set is a thing without order. Depending on set order across languages gets tricky.

You are probably familiar with the Java sorted containers option provided by the compiler:
$ thrift -gen java:sorted_containers my.thrift

C++ has a similar-but-different feature allowing the exact implementation container to be specified but within the IDL using the cpp_type keyword. I think both of these features would be better off if replaced by language specific annotations in the IDL. This would make the approach consistent across languages (using annotations), get rid of the odd ball C++ only keyword and open up the Java solution (not o mention other languages) to using any container you like (be it TreeSet, LinkedHashSet or HashSet).
                  
> Use LinkedHashSet instead of HashSet in generated java rpc code
> ---------------------------------------------------------------
>
>                 Key: THRIFT-2115
>                 URL: https://issues.apache.org/jira/browse/THRIFT-2115
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Java - Compiler
>    Affects Versions: 0.9
>            Reporter: Jeff Nelson
>
> Generated java code that returns a generic Set<?> should use a LinkedHashSet instead of a HashSet so that the iteration order is maintained from server to client.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira