[ https://issues.apache.org/jira/browse/THRIFT-4513?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16409151#comment-16409151 ]
ASF GitHub Bot commented on THRIFT-4513: ---------------------------------------- GitHub user romanoid opened a pull request: https://github.com/apache/thrift/pull/1517 THRIFT-4513: fix bug in comparator introduced by e58f75d Fix ordering bug for the comparator introduced by https://github.com/apache/thrift/pull/1505 You can merge this pull request into a Git repository by running: $ git pull https://github.com/romanoid/thrift fix-incorrect-comparator Alternatively you can review and apply these changes as the patch at: https://github.com/apache/thrift/pull/1517.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #1517 ---- commit 4df9b40c99e600e51e6203bb1abaa250751f22fc Author: Roman Soroka <romanoid@...> Date: 2018-03-22T07:07:23Z THRIFT-4513: fix bug in comparator introduced by e58f75d ---- > thrift generated code is not stable for constants > ------------------------------------------------- > > Key: THRIFT-4513 > URL: https://issues.apache.org/jira/browse/THRIFT-4513 > Project: Thrift > Issue Type: Improvement > Components: Compiler (General) > Reporter: Roman Soroka > Assignee: James E. King, III > Priority: Major > Fix For: 0.12.0 > > > In certain cases, output generated with java compiler is unstable, this > prevents correct incremental generation, artifact caching, etc. > This is especially crucible if the goal is reproducible builds: same results > for the same source inputs. > Here's example: > Let's say we have thrift definition: > const map<string, Enum1Enum2> CONSTANT_MAP = > { 'key1' : \\{"enum1" : Enum1.ENUM1_VALUE1, "enum2" : Enum2.ENUM2_VALUE} > , > 'key2' : \{"enum1" : Enum1.ENUM1_VALUE2, "enum2" : Enum2.ENUM2_VALUE}, > 'key3' : \{"enum1" : Enum1.ENUM1_VALUE3, "enum2" : Enum2.ENUM2_VALUE}, > .... > } > Compiler generates code like: > public static final java.util.Map<java.lang.String,Enum1Enum2> CONSTANT_MAP = > new java.util.HashMap<java.lang.String,Enum1Enum2>(); > static { > Enum1Enum2 tmp199 = new Enum1Enum2(); > tmp199.setEnum1(com.java.package.Enum1.ENUM1_VALUE2); > tmp199.setEnum2(com.java.package.Enum2.ENUM2_VALUE); > CONSTANT_MAP.put("key2", tmp199); > Enum1Enum2 tmp200 = new Enum1Enum2(); > tmp200.setEnum1(com.java.package.Enum1.ENUM1_VALUE1); > tmp200.setEnum2(com.java.package.Enum2.ENUM2_VALUE); > CONSTANT_MAP.put("key1", tmp200); > Enum1Enum2 tmp201 = new Enum1Enum2(); > tmp201.setEnum1(com.java.package.Enum1.ENUM1_VALUE3); > tmp201.setEnum2(com.java.package.Enum2.ENUM2_VALUE); > CONSTANT_MAP.put("key3", tmp201); > Possible reorderings: > 1. Values are added in different order from run to run. > 2. Set methods in value construction may be called in different order. > Note: this results in equivalent java maps, so there is no runtime issues. > Proposed remedy: > When building construction of Constants from JSON, java code generator > should use by-key ordering. > -- This message was sent by Atlassian JIRA (v7.6.3#76005)