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

Roger Meier commented on THRIFT-1203:
-------------------------------------

Yes, current implementation is order-insensitive.

http://wiki.apache.org/thrift/ThriftTypes mentions that Java uses HashMap

The spec at http://download.oracle.com/javase/1.4.2/docs/api/java/util/Map.html 
says
"The order of a map is defined as the order in which the iterators on the map's 
collection views return their elements. Some map implementations, like the 
TreeMap class, make specific *guarantees as to their order*; others, like the 
*HashMap* class, *do not*."

TreeMap vs. HashMap => What would it cost?

What about other languages?
Do they take care on the order of Map types?

> Java server returns JSON map items in the wrong order
> -----------------------------------------------------
>
>                 Key: THRIFT-1203
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1203
>             Project: Thrift
>          Issue Type: Bug
>          Components: Java - Compiler, Java - Library
>    Affects Versions: 0.6, 0.7
>            Reporter: Henrique Mendonca
>            Priority: Minor
>              Labels: java, test, test-server
>
> This is a old bug I have forgotten to register.
> lib/js/test uses a Java server to run its unit tests, and by doing so I could 
> see that there is a small problem on the Java JSON map decoder.
> The unit test "testMap" should echo a map<int,int> back to the client without 
> changing it, but it's messing up with the items order, e.g. {7=77, 8=88, 
> 9=99} returns {8=88, 9=99, 7=77}
> To run the server:
> thrift-trunk/lib/java$ ant compile-test
> thrift-trunk/lib/js/test$ ant testserver
> and go to http://localhost:8088/test/test.html
> Java test server console output:
> [java] Incoming content: 
> [1,"testMap",1,0,{"1":{"map":["i32","i32",3,{"7":77,"8":88,"9":99}]}}]
> [java] testMap({{8=88, 9=99, 7=77}})
> [java] Outgoing content: 
> [1,"testMap",2,0,{"0":{"map":["i32","i32",3,{"8":88,"9":99,"7":77}]}}]
> It's minor but it would be nice if any Java developer could have a look on it.
> Thanks a lot.
> ps.: the same works with a cpp server

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to