Skip to content

Commit

Permalink
Fix thrown exception in reflective placeholder evaluator
Browse files Browse the repository at this point in the history
  • Loading branch information
shitzuu committed Aug 15, 2024
1 parent 9986852 commit ff55474
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public CompletableFuture<EvaluatedPlaceholder> evaluate(
if (matcher.start() == 0) {
currentVariableName = path;
current = context.getValue(path);
if (matcher.hitEnd()) {
return asEvaluatedPlaceholder(placeholder, current);
}
continue;
}

Expand All @@ -51,7 +54,7 @@ public CompletableFuture<EvaluatedPlaceholder> evaluate(
final CompletableFuture<?> evaluatedValue =
current.thenApply(parent -> invokeMethodHandle(parent, getMethodHandle(parent, path)));
if (matcher.hitEnd()) {
return evaluatedValue.thenApply(value -> new EvaluatedPlaceholder(placeholder, value));
return asEvaluatedPlaceholder(placeholder, evaluatedValue);
}

current = evaluatedValue;
Expand All @@ -60,6 +63,11 @@ public CompletableFuture<EvaluatedPlaceholder> evaluate(
return completedFuture(null);
}

private CompletableFuture<EvaluatedPlaceholder> asEvaluatedPlaceholder(
final Placeholder placeholder, final CompletableFuture<?> evaluatedValue) {
return evaluatedValue.thenApply(value -> new EvaluatedPlaceholder(placeholder, value));
}

private Object invokeMethodHandle(final Object parent, final MethodHandle handle) {
try {
return handle.invoke(parent);
Expand Down

0 comments on commit ff55474

Please sign in to comment.