NIFI-7732: When encountering the end of an Expression Language Expression in the ELAwareParameterParser, ensure that we reset 'oddDollarCount' variable back to false

This commit is contained in:
Mark Payne 2020-08-12 10:36:14 -04:00 committed by Bryan Bende
parent 869c4236c4
commit 9e1e17d3f3
3 changed files with 47 additions and 1 deletions

View File

@ -69,7 +69,6 @@ public class ExpressionLanguageAwareParameterParser extends AbstractParameterPar
continue;
}
if (sequentialStartTags > 0) {
final ParameterToken token = parseParameterToken(input, i, sequentialStartTags, tokens);
@ -87,6 +86,7 @@ public class ExpressionLanguageAwareParameterParser extends AbstractParameterPar
if (--embeddedElCount == 0) {
expressionStart = -1;
oddDollarCount = false;
}
break;
case DOLLAR_SIGN:

View File

@ -187,4 +187,35 @@ public class TestExpressionLanguageAgnosticParameterParser {
assertEquals("hello", ((ParameterReference) token).getParameterName());
}
}
@Test
public void testMultipleReferencesDifferentExpressions() {
final ParameterParser parameterParser = new ExpressionLanguageAgnosticParameterParser();
final List<ParameterToken> tokens = parameterParser.parseTokens("${#{hello}}${#{there}}").toList();
assertEquals(2, tokens.size());
final ParameterToken firstToken = tokens.get(0);
assertTrue(firstToken.isParameterReference());
assertEquals("hello", ((ParameterReference) firstToken).getParameterName());
final ParameterToken secondToken = tokens.get(1);
assertTrue(secondToken.isParameterReference());
assertEquals("there", ((ParameterReference) secondToken).getParameterName());
}
@Test
public void testMultipleReferencesSameExpression() {
final ParameterParser parameterParser = new ExpressionLanguageAgnosticParameterParser();
final List<ParameterToken> tokens = parameterParser.parseTokens("${#{hello}:append(#{there})}").toList();
assertEquals(2, tokens.size());
final ParameterToken firstToken = tokens.get(0);
assertTrue(firstToken.isParameterReference());
assertEquals("hello", ((ParameterReference) firstToken).getParameterName());
final ParameterToken secondToken = tokens.get(1);
assertTrue(secondToken.isParameterReference());
assertEquals("there", ((ParameterReference) secondToken).getParameterName());
}
}

View File

@ -198,4 +198,19 @@ public class TestExpressionLanguageAwareParameterParser {
assertEquals("hello", ((ParameterReference) token).getParameterName());
}
}
@Test
public void testMultipleReferencesDifferentExpressions() {
final ParameterParser parameterParser = new ExpressionLanguageAwareParameterParser();
final List<ParameterToken> tokens = parameterParser.parseTokens("${#{hello}}${#{there}}").toList();
assertEquals(0, tokens.size());
}
@Test
public void testMultipleReferencesSameExpression() {
final ParameterParser parameterParser = new ExpressionLanguageAwareParameterParser();
final List<ParameterToken> tokens = parameterParser.parseTokens("${#{hello}:append(#{there})}").toList();
assertEquals(0, tokens.size());
}
}