Skip to content

Commit

Permalink
Reorder formatString expression check for JacksonEvent
Browse files Browse the repository at this point in the history
Signed-off-by: Taylor Gray <tylgry@amazon.com>
  • Loading branch information
graytaylor0 committed Oct 20, 2023
1 parent b981524 commit b08e9d4
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,18 @@ private String formatStringInternal(final String format, final ExpressionEvaluat
result += format.substring(fromIndex, position);
String name = format.substring(position + 2, endPosition);

Object val;
if (Objects.nonNull(expressionEvaluator) && expressionEvaluator.isValidExpressionStatement(name)) {
val = expressionEvaluator.evaluate(name, this);
} else {
Object val = null;

try {
val = this.get(name, Object.class);
if (val == null) {
} catch (final Exception e) {
LOG.debug("Received exception using Event key for formatting, now checking for Data Prepper expression: {}", e.getMessage());
}

if (val == null) {
if (Objects.nonNull(expressionEvaluator) && expressionEvaluator.isValidExpressionStatement(name)) {
val = expressionEvaluator.evaluate(name, this);
} else {
throw new EventKeyNotFoundException(String.format("The key %s could not be found in the Event when formatting", name));
}
}
Expand Down

0 comments on commit b08e9d4

Please sign in to comment.