Skip to content

Commit 7551fbc

Browse files
INGEST: Clean up Java8 Stream Usage (#32059) (#32485)
* GrokProcessor: Rationalize the loop over the map to save allocations and indirection * IngestDocument: Rationalize way we append to `List`
1 parent adeec7e commit 7551fbc

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/GrokProcessor.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ public void execute(IngestDocument ingestDocument) throws Exception {
6868
throw new IllegalArgumentException("Provided Grok expressions do not match field value: [" + fieldValue + "]");
6969
}
7070

71-
matches.entrySet().stream()
72-
.forEach((e) -> ingestDocument.setFieldValue(e.getKey(), e.getValue()));
71+
matches.forEach(ingestDocument::setFieldValue);
7372

7473
if (traceMatch) {
7574
if (matchPatterns.size() > 1) {

server/src/main/java/org/elasticsearch/ingest/IngestDocument.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,8 +531,7 @@ private static List<Object> appendValues(Object maybeList, Object value) {
531531

532532
private static void appendValues(List<Object> list, Object value) {
533533
if (value instanceof List) {
534-
List<?> valueList = (List<?>) value;
535-
valueList.stream().forEach(list::add);
534+
list.addAll((List<?>) value);
536535
} else {
537536
list.add(value);
538537
}

0 commit comments

Comments
 (0)