Skip to content

Commit

Permalink
[ML] Fix find_file_structure NPE with should_trim_fields (#35465)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
droberts195 committed Nov 13, 2018
1 parent f28c1cd commit 65f8ec5
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ static DelimitedFileStructureFinder makeDelimitedFileStructureFinder(List<String
int lineNumber = lineNumbers.get(index);
Map<String, String> sampleRecord = new LinkedHashMap<>();
Util.filterListToMap(sampleRecord, columnNames,
trimFields ? row.stream().map(String::trim).collect(Collectors.toList()) : row);
trimFields ? row.stream().map(field -> (field == null) ? null : field.trim()).collect(Collectors.toList()) : row);
sampleRecords.add(sampleRecord);
sampleMessages.add(
sampleLines.subList(prevMessageEndLineNumber + 1, lineNumbers.get(index)).stream().collect(Collectors.joining("\n")));
Expand Down

0 comments on commit 65f8ec5

Please sign in to comment.