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

Edson Tirelli (JIRA) jira-events at lists.jboss.org
Wed Nov 26 10:51:01 EST 2008


     [ https://jira.jboss.org/jira/browse/JBRULES-1591?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Edson Tirelli updated JBRULES-1591:
-----------------------------------

    Fix Version/s: 5.0.0.CR1
                       (was: 5.0.0.M3)


> 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.CR1
>
>
> 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