Inside
DMNFEELHelper#compileFeelExpression(DMNCompilerContext, String, DMNModelImpl, DMNElement, Msg.Message, Object...) {
...
CompiledExpression ce = feel.compile( expression, feelctx );
processEvents( model, element, errorMsg, msgParams );
return ce;
}
a CompiledExpression is returned even in presence of Syntax errors, that are simply sent to MsgUtil.
Then, the calling code
DMNEvaluatorCompiler#compileLiteralExpression(DMNCompilerContext, DMNModelImpl, DMNBaseNode, String, LiteralExpression) {
...
CompiledExpression compiledExpression = ctx.getFeelHelper().compileFeelExpression(ctx,
exprText,
model,
expression,
Msg.ERR_COMPILING_FEEL_EXPR_FOR_NAME_ON_NODE,
exprText,
exprName,
node.getIdentifierString() );
evaluator = new DMNLiteralExpressionEvaluator(compiledExpression, expression, ctx.getFeelHelper().newFEELInstance());
...
ignores the error messages, set the evaluator, and uses it to evaluate the model.
The result of all that is inconsistent, since
- on one side, the expression has syntax errors, so it should be completely discarded
- but on the other side, an evaluator is instantiated and fired, leading to some kind of result.
This is demonstrated by the attached DMN-Invalid.txt and the following snippet:
File modelFile = FileUtils.getFile("DMN-Invalid.dmn");
Resource modelResource = ResourceFactory.newFileResource(modelFile);
DMNRuntime dmnRuntime = DMNRuntimeBuilder.fromDefaults().buildConfiguration()
.fromResources(Collections.singletonList(modelResource)).getOrElseThrow(RuntimeException::new);
String nameSpace = "https://kie.org/dmn/_C41C5BB7-C6D3-44AC-AA11-8C6669A1067C";
final DMNModel dmnModel = dmnRuntime.getModel(
nameSpace,
"DMN_9A35369C-E843-446F-A720-2A41B827FB8D");
final DMNContext context = DMNFactory.newContext();
context.set( "Person Age", 24 );
final DMNResult dmnResult = dmnRuntime.evaluateAll(dmnModel, context );
Result
DMNResultImpl{
context={
Person Age: 24
Can Drive?: true
}
}
@baldimir @yesamer
Inside
a CompiledExpression is returned even in presence of Syntax errors, that are simply sent to MsgUtil.
Then, the calling code
ignores the error messages, set the evaluator, and uses it to evaluate the model.
The result of all that is inconsistent, since
This is demonstrated by the attached DMN-Invalid.txt and the following snippet:
Result
@baldimir @yesamer