Skip to content

Commit cb8f44f

Browse files
committed
Restore old sorting behaviour
- In #946 we added new ways to add items to single selector while still keeping Map<String, String>. Order to keep old sorting behaviour we try to pass incoming map via new HashMap as that was a way it worked. This should limit risks for breaking things in a patch release.
1 parent 4eab8be commit cb8f44f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

spring-shell-core/src/main/java/org/springframework/shell/component/flow/BaseSingleItemSelector.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import java.util.ArrayList;
1919
import java.util.Comparator;
20+
import java.util.HashMap;
2021
import java.util.List;
2122
import java.util.Map;
2223
import java.util.function.Consumer;
@@ -81,7 +82,11 @@ public SingleItemSelectorSpec selectItem(String name, String item) {
8182

8283
@Override
8384
public SingleItemSelectorSpec selectItems(Map<String, String> selectItems) {
84-
List<SelectItem> items = selectItems.entrySet().stream()
85+
// TODO: we changed to keep items as SelectItem's, to try to keep old sorting
86+
// behaviour we go via HashMap gh-946. Later we should remove this step.
87+
Map<String, String> selectItemsMap = new HashMap<>();
88+
selectItemsMap.putAll(selectItems);
89+
List<SelectItem> items = selectItemsMap.entrySet().stream()
8590
.map(e -> SelectItem.of(e.getKey(), e.getValue()))
8691
.collect(Collectors.toList());
8792
selectItems(items);

0 commit comments

Comments
 (0)