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
commit 5cbd6cee0961d9eb57db8093fae8c4bf12a396b1 Author: Alex Heneveld <a...@cloudsoft.io> AuthorDate: Fri Feb 2 19:38:17 2024 +0000 allow let workflow step to accept interpolated expressions with spaces --- .../steps/variables/SetVariableWorkflowStep.java | 33 +++++++++++++++------- 1 file changed, 23 insertions(+), 10 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 9afebbd3df..493d89ba8c 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 @@ -223,17 +223,30 @@ public class SetVariableWorkflowStep extends WorkflowStepDefinition { Object process(String input) { if (Strings.isBlank(input)) return input; - // first deal with internal quotes - QuotedStringTokenizer qst = qst(input); - List<String> wordsByQuote; - if (qst.isQuoted(input)) { - // special treatment if whole line is quoted - wordsByQuote = MutableList.of(input); - } else { - wordsByQuote = qst.remainderAsList(); + List<String> wordsByQuote = null; + try { + // first deal with internal quotes + QuotedStringTokenizer qst = qst(input); + if (qst.isQuoted(input)) { + // special treatment if whole line is quoted + wordsByQuote = MutableList.of(input); + } else { + wordsByQuote = qst.remainderAsList(); + } + // then look for operators etc + return process(wordsByQuote); + } 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); + } + } + throw Exceptions.propagate(e); } - // then look for operators etc - return process(wordsByQuote); } QuotedStringTokenizer qst(String input) {