LinkedHashMap entrySet's order not being preserved in a stream (Android)

隐身守侯 提交于 2019-12-05 05:38:21

This behavior is a known bug in Android's 7.0 / 7.1 implementation of LinkedHashMap.

The LinkedHashMap's collection views' spliterators for entrySet, values and keySet correctly report that they are ORDERED but actually they aren't because the spliterator implementation of the parent class (HashMap) is used internally.

This behavior has already been documented in the Javadoc and workarounds are also proposed there.

The fix has been commited on 2016-08-16 and will appear in the next Android release.

For clarification: Google became aware of this bug at first in 2017-01, so the "fix" mentioned above was an accidental fix. If they had known about this problem earlier, the resolution would have been included in 7.1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!