This is an automated email from the ASF dual-hosted git repository.
heneveld pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git
The following commit(s) were added to refs/heads/master by this push:
new d5fdb06ce6 tighten how interpolated expressions with spaces are
accepted
d5fdb06ce6 is described below
commit d5fdb06ce6052e3e9097162f3db69d9ce2956fab
Author: Alex Heneveld <[email protected]>
AuthorDate: Fri Feb 2 22:25:10 2024 +0000
tighten how interpolated expressions with spaces are accepted
---
.../workflow/steps/variables/SetVariableWorkflowStep.java | 13 ++++++++-----
.../core/workflow/WorkflowInputOutputExtensionTest.java | 3 +++
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git
a/core/src/main/java/org/apache/brooklyn/core/workflow/steps/variables/SetVariableWorkflowStep.java
b/core/src/main/java/org/apache/brooklyn/core/workflow/steps/variables/SetVariableWorkflowStep.java
index 493d89ba8c..79b41185fc 100644
---
a/core/src/main/java/org/apache/brooklyn/core/workflow/steps/variables/SetVariableWorkflowStep.java
+++
b/core/src/main/java/org/apache/brooklyn/core/workflow/steps/variables/SetVariableWorkflowStep.java
@@ -19,6 +19,7 @@
package org.apache.brooklyn.core.workflow.steps.variables;
import com.google.common.reflect.TypeToken;
+import freemarker.core.ParseException;
import org.apache.brooklyn.api.mgmt.ManagementContext;
import org.apache.brooklyn.config.ConfigKey;
import org.apache.brooklyn.core.config.ConfigKeys;
@@ -238,11 +239,13 @@ public class SetVariableWorkflowStep extends
WorkflowStepDefinition {
} catch (Exception e) {
Exceptions.propagateIfFatal(e);
if (wordsByQuote==null || wordsByQuote.size()>1) {
- // try again with the whole thing as tokens, if multiple
words, or couldn't string tokenize
- try {
- return process(MutableList.of(input));
- } catch (Exception e2) {
- log.debug("Failed to process expression as tokens or
as string; preferring error from former, but error from latter was: "+e2);
+ if (Exceptions.getCausalChain(e).stream().anyMatch(cause
-> cause instanceof ParseException)) {
+ // try again with the whole thing as tokens, if it is
an interpolated string with spaces inside it
+ try {
+ return process(MutableList.of(input));
+ } catch (Exception e2) {
+ log.debug("Failed to process expression as tokens
or as string; preferring error from former, but error from latter was: " + e2);
+ }
}
}
throw Exceptions.propagate(e);
diff --git
a/core/src/test/java/org/apache/brooklyn/core/workflow/WorkflowInputOutputExtensionTest.java
b/core/src/test/java/org/apache/brooklyn/core/workflow/WorkflowInputOutputExtensionTest.java
index 81e3c5c0c5..5e938b9310 100644
---
a/core/src/test/java/org/apache/brooklyn/core/workflow/WorkflowInputOutputExtensionTest.java
+++
b/core/src/test/java/org/apache/brooklyn/core/workflow/WorkflowInputOutputExtensionTest.java
@@ -437,6 +437,9 @@ public class WorkflowInputOutputExtensionTest extends
BrooklynMgmtUnitTestSuppor
assertLetGives.apply("\"\\\"${person}\\\" is person \"",
"\"${person}\" is person ");
Asserts.assertFails(() -> invoke.accept("\"\\\"${person}\\\" is
\"person \""));
assertLetGives.apply("\"\\\"${person}\" is \"person \"", "\"${person}
is person ");
+
+ // if there are spaces inside the interpolated expression, don't use
the quote strategy
+ assertLetGives.apply("${ person } is \"${person}\"", "Anna is
\"Anna\"");
}
@Test