Use LinkedHashMap for a deterministic iteration order in


The tests in liquibase.util.DependencyUtilTest#testIndependentBranchesCase can fail due to a different iteration order of HashMap. The assertion failure is presented as follows:
expected:<a, o, x, b, p1, p2, y, c1, c2, r1, r2, s, s2, s3>
but was:<x, a, o, y, b, p1, p2, c1, c2, r1, r2, s, s2, s3>
at liquibase.util.DependencyUtilTest.testIndependentBranchesCase(

The root cause of this assertion failure lies in the variable nodes in , which is a HashMap. 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:

The fix is to change it to a LinkedHashMap so that the iteration order remains stable and the failure will not occur any more. In this way, the test will be more stable.


Ubuntu Jdk8



Affects versions