mirror of https://github.com/apache/nifi.git
NIFI-6127: Fixed NPE in match() and find() EL functions when attribute doesn't exist
This closes #3378. Signed-off-by: Koji Kawamura <ijokarumawak@apache.org>
This commit is contained in:
parent
0cb15cfb1a
commit
06f41ac6f8
|
@ -53,7 +53,11 @@ public class FindEvaluator extends BooleanEvaluator {
|
|||
}
|
||||
final Pattern pattern;
|
||||
if (compiledPattern == null) {
|
||||
pattern = Pattern.compile(search.evaluate(attributes).getValue());
|
||||
String expression = search.evaluate(attributes).getValue();
|
||||
if (expression == null) {
|
||||
return new BooleanQueryResult(false);
|
||||
}
|
||||
pattern = Pattern.compile(expression);
|
||||
} else {
|
||||
pattern = compiledPattern;
|
||||
}
|
||||
|
|
|
@ -53,7 +53,11 @@ public class MatchesEvaluator extends BooleanEvaluator {
|
|||
}
|
||||
final Pattern pattern;
|
||||
if (compiledPattern == null) {
|
||||
pattern = Pattern.compile(search.evaluate(attributes).getValue());
|
||||
String expression = search.evaluate(attributes).getValue();
|
||||
if (expression == null) {
|
||||
return new BooleanQueryResult(false);
|
||||
}
|
||||
pattern = Pattern.compile(expression);
|
||||
} else {
|
||||
pattern = compiledPattern;
|
||||
}
|
||||
|
|
|
@ -1324,6 +1324,9 @@ public class TestQuery {
|
|||
assertEquals("false", secondEvaluation);
|
||||
|
||||
verifyEquals("${dotted:matches('abc\\.xyz')}", attributes, true);
|
||||
|
||||
// Test for matches(null)
|
||||
assertEquals("false", Query.evaluateExpressions("${abc:matches(${not.here})}", attributes, null));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1344,6 +1347,9 @@ public class TestQuery {
|
|||
assertEquals("false", secondEvaluation);
|
||||
|
||||
verifyEquals("${dotted:find('\\.')}", attributes, true);
|
||||
|
||||
// Test for find(null)
|
||||
assertEquals("false", Query.evaluateExpressions("${abc:find(${not.here})}", attributes, null));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue