tighten how interpolated expressions with spaces are accepted
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 493d89b..79b4118 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 @@
} 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 81e3c5c..5e938b9 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 @@
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