[jboss-jira] [JBoss JIRA] Commented: (JBRULES-1591) Newline in eval expression causes NullPointerException

Julien Kronegg (JIRA) jira-events at lists.jboss.org
Fri Sep 12 10:26:21 EDT 2008


    [ https://jira.jboss.org/jira/browse/JBRULES-1591?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12429350#action_12429350 ] 

Julien Kronegg commented on JBRULES-1591:
-----------------------------------------

It seems that parsing does not support escape characters very well: another guy found problems on the same code line on \" character  http://www.nabble.com/problem-escaping-quote-in-eval.-td19254011.html

> Newline in eval expression causes NullPointerException
> ------------------------------------------------------
>
>                 Key: JBRULES-1591
>                 URL: https://jira.jboss.org/jira/browse/JBRULES-1591
>             Project: JBoss Drools
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>    Affects Versions: 4.0.7
>            Reporter: Brian Stiles
>            Assignee: Edson Tirelli
>             Fix For:  5.0.0.M2
>
>
> If a newline splits an eval expression, an NPE is thrown at org.drools.rule.PredicateConstraint.createContextEntry(PredicateConstraint.java:201).
> The following code demonstrates the problem.  Removing the newline from the eval expression solves the problem.
> --
> package sample;
> import java.io.StringReader;
> import org.drools.RuleBase;
> import org.drools.RuleBaseConfiguration;
> import org.drools.RuleBaseFactory;
> import org.drools.StatefulSession;
> import org.drools.compiler.PackageBuilder;
> import org.drools.compiler.PackageBuilderConfiguration;
> public class ExpressionProblem {
>     public static class Tester {
>         public boolean test(Object o1, Object o2) {
>             return o1.equals(o2);
>         }
>     }
>     public static void main(String[] args) throws Exception {
>         final PackageBuilderConfiguration packageBuilderConfiguration =
>                 new PackageBuilderConfiguration();
>         final PackageBuilder packageBuilder = new PackageBuilder(packageBuilderConfiguration);
>         packageBuilder.addPackageFromDrl(new StringReader("\n"
>                 + "package sample\n"
>                 + "\n"
>                 + "import sample.ExpressionProblem.Tester;\n"
>                 + "global sample.ExpressionProblem.Tester tester;\n"
>                 + "\n"
>                 + "rule MyRule\n"
>                 + "\n"
>                 + "    when\n"
>                 + "        Integer($f : this, eval(tester.test($f,\n" // OFFENDING NEWLINE
>                 + "                                          $f)))\n"
>                 + "    then \n"
>                 + "        System.out.println($f);\n"
>                 + "end \n"
>                 + ""));
>         final RuleBaseConfiguration ruleBaseConfiguration = new RuleBaseConfiguration();
>         final RuleBase ruleBase = RuleBaseFactory.newRuleBase(ruleBaseConfiguration);
>         ruleBase.addPackage(packageBuilder.getPackage());
>         final StatefulSession session = ruleBase.newStatefulSession(false);
>         session.setGlobal("tester", new Tester());
>         session.insert(1);
>         session.fireAllRules();
>     }
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list