Skip to content

Commit 09965cb

Browse files
author
David Roberts
authored
[ML] Fix find_file_structure NPE with should_trim_fields (#35465)
The NPE would occur if should_trim_field was overridden to true and any field value was completely blank. This change defends against this situation. Fixes #35462
1 parent a18b599 commit 09965cb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/filestructurefinder/DelimitedFileStructureFinder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ static DelimitedFileStructureFinder makeDelimitedFileStructureFinder(List<String
8282
int lineNumber = lineNumbers.get(index);
8383
Map<String, String> sampleRecord = new LinkedHashMap<>();
8484
Util.filterListToMap(sampleRecord, columnNames,
85-
trimFields ? row.stream().map(String::trim).collect(Collectors.toList()) : row);
85+
trimFields ? row.stream().map(field -> (field == null) ? null : field.trim()).collect(Collectors.toList()) : row);
8686
sampleRecords.add(sampleRecord);
8787
sampleMessages.add(
8888
sampleLines.subList(prevMessageEndLineNumber + 1, lineNumbers.get(index)).stream().collect(Collectors.joining("\n")));

0 commit comments

Comments
 (0)