Skip to content

Commit f117e48

Browse files
Use for loops instead of streams
1 parent b7f0490 commit f117e48

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetAliasesAction.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,22 @@ static RestResponse buildRestResponse(
8686
final Set<String> indicesToDisplay = new HashSet<>();
8787
final Set<String> returnedAliasNames = new HashSet<>();
8888
if (aliasesExplicitlyRequested) {
89-
responseAliasMap.entrySet().stream().filter(entry -> entry.getValue().isEmpty() == false).forEach(entry -> {
90-
// only display indices that have aliases
91-
indicesToDisplay.add(entry.getKey());
92-
entry.getValue().forEach(aliasMetadata -> returnedAliasNames.add(aliasMetadata.alias()));
93-
});
89+
for (final Map.Entry<String, List<AliasMetadata>> cursor : responseAliasMap.entrySet()) {
90+
final var aliases = cursor.getValue();
91+
if (aliases.isEmpty() == false) {
92+
// only display indices that have aliases
93+
indicesToDisplay.add(cursor.getKey());
94+
for (final AliasMetadata aliasMetadata : cursor.getValue()) {
95+
returnedAliasNames.add(aliasMetadata.alias());
96+
}
97+
}
98+
}
9499

95-
dataStreamAliases.entrySet()
96-
.stream()
97-
.flatMap(entry -> entry.getValue().stream())
98-
.forEach(dataStreamAlias -> returnedAliasNames.add(dataStreamAlias.getName()));
100+
for (final Map.Entry<String, List<DataStreamAlias>> entry : dataStreamAliases.entrySet()) {
101+
for (final DataStreamAlias dataStreamAlias : entry.getValue()) {
102+
returnedAliasNames.add(dataStreamAlias.getName());
103+
}
104+
}
99105
}
100106

101107
// compute explicitly requested aliases that would not be returned in the result

0 commit comments

Comments
 (0)