mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-09 14:34:43 +00:00
In Priority there is a field named values that represents an ordered, by priority, list of all priorities. Yet, this collection is modifiable and this collection is exposed via the public API. This means that consumers can modify this list potentially leading to complete chaos. This commit modifies this field so that it is unmodifiable, documents that the returned collection is unmodifiable, and returns total order to the world. We also punish the bad consumer here by making them make a copy of the returned collection with which they can do as they please. This fixes a puzzling test failure which only arises if the two tests (PrioritizedExecutorsTests#testPriorityQueue and PriorityTests#testCompareTo run in the same JVM, and run in the right order). Relates #19447