Skip to content

Commit 2a2b868

Browse files
committed
Change to traditional looping
1 parent e00aef1 commit 2a2b868

File tree

1 file changed

+10
-9
lines changed
  • modules/ingest-common/src/main/java/org/elasticsearch/ingest/common

1 file changed

+10
-9
lines changed

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

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import java.util.Set;
3636
import java.util.regex.Matcher;
3737
import java.util.regex.Pattern;
38-
import java.util.stream.Collectors;
3938

4039
import static java.time.temporal.ChronoField.DAY_OF_MONTH;
4140
import static java.time.temporal.ChronoField.HOUR_OF_DAY;
@@ -163,7 +162,7 @@ final class CefParser {
163162
Sets.union(FIELD_MAPPINGS.keySet(), Set.copyOf(FIELD_MAPPINGS.values()))
164163
);
165164

166-
private static final Map<String, DataType> FIELDS = Map.<String, DataType>ofEntries(
165+
private static final Map<String, DataType> FIELDS_WITH_TYPES = Map.<String, DataType>ofEntries(
167166
entry("@timestamp", DataType.TimestampType),
168167
entry("destination.bytes", DataType.LongType),
169168
entry("destination.domain", DataType.StringType),
@@ -348,13 +347,15 @@ private void processExtensions(String cefString, int extensionStart, CEFEvent ev
348347
}
349348

350349
// Translate extensions to possible ECS fields
351-
Map<String, Object> translatedFields = extensions.entrySet()
352-
.stream()
353-
.filter(entry -> FIELD_MAPPINGS.containsKey(entry.getKey()))
354-
.collect(Collectors.toMap(entry -> FIELD_MAPPINGS.get(entry.getKey()), entry -> {
355-
DataType fieldType = FIELDS.get(FIELD_MAPPINGS.get(entry.getKey()));
356-
return convertValueToType(entry.getValue(), fieldType);
357-
}));
350+
Map<String, Object> translatedFields = new HashMap<>();
351+
for (Map.Entry<String, String> entry : extensions.entrySet()) {
352+
if (FIELD_MAPPINGS.containsKey(entry.getKey())) {
353+
String mappedKey = FIELD_MAPPINGS.get(entry.getKey());
354+
DataType fieldType = FIELDS_WITH_TYPES.get(mappedKey);
355+
translatedFields.put(mappedKey, convertValueToType(entry.getValue(), fieldType));
356+
}
357+
}
358+
358359
// Add ECS translations to the root of the document
359360
if (translatedFields.isEmpty() == false) {
360361
translatedFields.forEach(event::addRootMapping);

0 commit comments

Comments
 (0)