[
https://issues.apache.org/jira/browse/HADOOP-9465?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13625068#comment-13625068
]
Billie Rinaldi commented on HADOOP-9465:
----------------------------------------
I'm not sure why LinkedHashMap would necessarily solve this issue, since the
order in which entries are put into the map is the order in which they are
retrieved from the Properties Hashtable.
Currently the string generated by JobImpl.getWorkflowAdjacencies is not
intended to have any particular ordering. Here are some other possible ways to
address the test issue:
1) Make getWorkflowAdjacencies apply an ordering (e.g. putting the entries
obtained by Configuration.getValByRegex into a sorted map instead of just using
the HashMap it returns, presumably also with an effect on performance).
2) Instead of testing an exact string with an assumed ordering, split the
string on spaces and ensure each element appears as expected.
3) Only test a single adjacency entry to avoid the ordering issue entirely.
> TestJobImpl->testJobNoTasks fails ..
> ------------------------------------
>
> Key: HADOOP-9465
> URL: https://issues.apache.org/jira/browse/HADOOP-9465
> Project: Hadoop Common
> Issue Type: Bug
> Components: conf
> Affects Versions: 2.0.3-alpha
> Environment: Linux + IBM JAVA 6
> Reporter: Amir Sanjar
> Attachments: HADOOP-9465.patch
>
>
> I am not sure if this is a testcase or a design issue. During execution of
> TestJobImpl->testJobNoTasks() there is an assertion made based on the order
> of key/value pairs stored in adjacency list. However adjacency list was
> created by Configuration->getValByRegex() as a HashMap (order is not
> guaranteed):
> Testcase:
> JobSubmittedEventHandler jseHandler = new
> JobSubmittedEventHandler("testId",
> "testName", "testNodeName", "\"key2\"=\"value2\" \"key1\"=\"value1\"
> ");
> ....
> ....
> try {
> Assert.assertTrue(jseHandler.getAssertValue()); <===
> Configuration->getValByRegex():
> public Map<String,String> getValByRegex(String regex) {
> Pattern p = Pattern.compile(regex);
> Map<String,String> result = new HashMap<String,String>(); <=======
>
> as we all know, HashMap makes absolutely no guarantees about the iteration
> order. It can (and will) even change completely when new elements are added.
> Changing HashMap to LinkedHashMap fixes the ordering inconsistency, however
> with a small performance side effect.
--
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