From ff554745c260c9dbdef9f2a49d2c3b99b9aa5cd4 Mon Sep 17 00:00:00 2001 From: shitzuu Date: Thu, 15 Aug 2024 18:49:04 +0200 Subject: [PATCH] Fix thrown exception in reflective placeholder evaluator --- .../reflection/ReflectivePlaceholderEvaluator.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/honey-common/src/dev/shiza/honey/reflection/ReflectivePlaceholderEvaluator.java b/honey-common/src/dev/shiza/honey/reflection/ReflectivePlaceholderEvaluator.java index 731639f..3416a3c 100644 --- a/honey-common/src/dev/shiza/honey/reflection/ReflectivePlaceholderEvaluator.java +++ b/honey-common/src/dev/shiza/honey/reflection/ReflectivePlaceholderEvaluator.java @@ -39,6 +39,9 @@ public CompletableFuture evaluate( if (matcher.start() == 0) { currentVariableName = path; current = context.getValue(path); + if (matcher.hitEnd()) { + return asEvaluatedPlaceholder(placeholder, current); + } continue; } @@ -51,7 +54,7 @@ public CompletableFuture 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; @@ -60,6 +63,11 @@ public CompletableFuture evaluate( return completedFuture(null); } + private CompletableFuture 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);