[ https://issues.apache.org/jira/browse/FLINK-16453?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Flink Jira Bot updated FLINK-16453: ----------------------------------- Labels: stale-minor (was: ) > A test failure in KafkaTest > --------------------------- > > Key: FLINK-16453 > URL: https://issues.apache.org/jira/browse/FLINK-16453 > Project: Flink > Issue Type: Bug > Components: Connectors / Kafka > Reporter: cpugputpu > Priority: Minor > Labels: stale-minor > > The tests in _org.apache.flink.table.descriptors.KafkaTest#testValidation_ > may fail. The unexpected behaviour is presented as follows: > testValidation(org.apache.flink.table.descriptors.KafkaTest) > java.lang.AssertionError: > expected:<{connector.property-version=1, > connector.startup-mode=specific-offsets, > connector.properties.kafka.stuff=42, connector.properties.zookeeper.stuff=12, > connector.type=kafka, > connector.specific-offsets=partition:0,offset:42;partition:1,offset:300, > connector.topic=MyTable, connector.version=0.11}> > but was:<{connector.property-version=1, > connector.startup-mode=specific-offsets, > connector.properties.kafka.stuff=42, > connector.properties.zookeeper.stuff=12, connector.type=kafka, > connector.specific-offsets=partition:1, > offset:300;partition:0,offset:42, connector.topic=MyTable, > connector.version=0.11}> > > The root cause of this order issue is regarding two HashMap variables > initialized: > this.specificOffsets = new HashMap<>(); > (flink-connectors/flink-connector-kafka-base/src/main/java/org/apache/flink/table/descriptors/Kafka.java) > final Map<Integer, Long> offsets = new > HashMap<>();(flink-connectors/flink-connector-kafka-base/src/test/java/org/apache/flink/table/descriptors/KafkaTest.java) > And the iteration of HashMap is here: > for (Map.Entry<Integer, Long> specificOffset : specificOffsets.entrySet()) > (in function _toConnectorProperties_ __ at _Kafka.java_) > The specification about HashMap says that "this class makes no guarantees as > to the order of the map; in particular, it does not guarantee that the order > will remain constant over time". The documentation is here for your > reference: https://docs.oracle.com/javase/8/docs/api/java/util/HashMap.html > > If I change the two HashMap vairables into LinkedHashMap,the failure will be > removed, making the test more stable. If you come up with better fix, please > be free to discuss with me. -- This message was sent by Atlassian Jira (v8.3.4#803005)