Skip to content

Commit

Permalink
fix: Potential NullPointerException if expression passed to '-o expr=…
Browse files Browse the repository at this point in the history
…...' returns null
  • Loading branch information
rsenden committed Jul 14, 2023
1 parent 9c7343d commit 8508aaf
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public void writeRecord(ObjectNode record) {

private String getFormattedRecord(ObjectNode record) {
try {
return JsonHelper.evaluateSpelExpression(record, expression, String.class);
var result = JsonHelper.evaluateSpelExpression(record, expression, String.class);
return result==null ? "" : result;
} catch ( Exception e ) {
throw new IllegalStateException(String.format("Error evaluating output expression:\n\tMessage: %s\n\tExpression: %s\n\tRecord: %s", e.getMessage(), getConfig().getOptions(), record.toPrettyString().replace("\n", "\n\t\t")));
}
Expand Down

0 comments on commit 8508aaf

Please sign in to comment.