You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kie.apache.org by "yurloc (via GitHub)" <gi...@apache.org> on 2024/03/12 14:16:50 UTC

Re: [PR] [new-parser] Add error listener to DrlExprParser [incubator-kie-drools]

yurloc commented on code in PR #5778:
URL: https://github.com/apache/incubator-kie-drools/pull/5778#discussion_r1521550986


##########
drools-compiler/src/main/java/org/drools/compiler/rule/builder/PatternBuilder.java:
##########
@@ -1805,15 +1805,15 @@ protected ConstraintConnectiveDescr parseExpression(final RuleBuildContext conte
                                                         final String expression) {
         DrlExprParser parser = DrlExprParserFactory.getDrlExprParser(context.getConfiguration().getOption(LanguageLevelOption.KEY));
         ConstraintConnectiveDescr result = parser.parse(normalizeEval(expression));
-        result.setResource(patternDescr.getResource());
-        result.copyLocation(original);
         if (parser.hasErrors()) {
             for (DroolsParserException error : parser.getErrors()) {
                 registerDescrBuildError(context, patternDescr,
                                         "Unable to parse pattern expression:\n" + error.getMessage());
             }
             return null;
         }
+        result.setResource(patternDescr.getResource());
+        result.copyLocation(original);

Review Comment:
   `parser.hasErrors()` check needs to be performed _before_ accessing `result`. If the parsers has errors, `result` is null.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org