[ 
https://issues.apache.org/jira/browse/HIVE-22952?focusedWorklogId=445105&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-445105
 ]

ASF GitHub Bot logged work on HIVE-22952:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 12/Jun/20 18:58
            Start Date: 12/Jun/20 18:58
    Worklog Time Spent: 10m 
      Work Description: cpugputpu opened a new pull request #929:
URL: https://github.com/apache/hive/pull/929


   The background information is presented here: 
https://issues.apache.org/jira/browse/HIVE-22952
   
   This PR aims to fix the issue without hurting any performance at all. It 
uses LinkedHashMap instead of HashMap in the test so that the test is no more 
flaky.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 445105)
    Time Spent: 0.5h  (was: 20m)

> Use LinkedHashMap in TestStandardObjectInspectors.java
> ------------------------------------------------------
>
>                 Key: HIVE-22952
>                 URL: https://issues.apache.org/jira/browse/HIVE-22952
>             Project: Hive
>          Issue Type: Bug
>          Components: Test, Tests
>            Reporter: cpugputpu
>            Priority: Minor
>              Labels: pull-request-available
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> The test in 
> _org.apache.hadoop.hive.serde2.objectinspector.TestStandardObjectInspectors#testStandardUnionObjectInspector_
>  can fail due to a different iteration order of HashMap. The failure is 
> presented as follows.
> org.junit.ComparisonFailure: 
> expected:<\{4:{6:"six",7:"seven",8:"eight"}}> 
> but was:<\{4:{6:"six",8:"eight",7:"seven"}}>
> The reason is that the assertion 
> _assertEquals("\{4:{6:\"six\",7:\"seven\",8:\"eight\"}}", 
> SerDeUtils.getJSONString(union, uoi1));_ compares a hard-coded string against 
> the string representation of a JSON object, which is implemented by a 
> HashMap. To get the string, the HashMap is iterated here at 
> _serde/src/java/org/apache/hadoop/hive/serde2/SerDeUtils.java:343_ 
> _for (Object entry : omap.entrySet())_
> 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]
>  
> The fix is to use LinkedHashMap instead of HashMap. In this way, the 
> non-deterministic behaviour is eliminated and the test will become more 
> stable.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to