[jboss-jira] [JBoss JIRA] (DROOLS-889) Ambiguity with 'end' keyword and end() method in drl file

Mario Fusco (JIRA) issues at jboss.org
Thu Aug 20 03:11:26 EDT 2015


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

Mario Fusco closed DROOLS-889.
------------------------------
    Fix Version/s: 6.3.0.CR2
       Resolution: Done


Fixed by https://github.com/droolsjbpm/drools/commit/49fdcf94b

> Ambiguity with 'end' keyword and end() method in drl file
> ---------------------------------------------------------
>
>                 Key: DROOLS-889
>                 URL: https://issues.jboss.org/browse/DROOLS-889
>             Project: Drools
>          Issue Type: Bug
>            Reporter: Mario Fusco
>            Assignee: Mario Fusco
>             Fix For: 6.3.0.CR2
>
>
> Trying to invoke a method called end() in the RHS of a rule, as in the test case pasted below, causes a compilation failure because drools interprets it as the 'end' soft keyword that terminates the rule. 
> {code}
>     @Test
>     public void testEndMethod() throws Exception {
>         // DROOLS-889
>         String drl =
>                 "import " + Pattern.class.getCanonicalName() + "\n" +
>                 "import " + Matcher.class.getCanonicalName() + "\n" +
>                 "global java.util.List list\n" +
>                 "rule \"Variable matches field\" when\n" +
>                 "    $emailAddress :String(this matches \"^.*[_A-Za-z0-9-\\\\+]+(\\\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\\\.[A-Za-z0-9]+)*(\\\\.[A-Za-z]{2,}).*$\")\n" +
>                 "then\n" +
>                 "    Pattern pattern=Pattern.compile(\"[_A-Za-z0-9-\\\\+]+(\\\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\\\.[A-Za-z0-9]+)*(\\\\.[A-Za-z]{2,})\");\n" +
>                 "    Matcher matcher=pattern.matcher($emailAddress);\n" +
>                 "    while(matcher.find()){\n" +
>                 "        list.add($emailAddress.substring(matcher.start(),matcher.end()));\n" +
>                 "    }\n" +
>                 "end\n";
>         KieSession ksession = new KieHelper().addContent(drl, ResourceType.DRL)
>                                              .build()
>                                              .newKieSession();
>         List<String> list = new ArrayList<String>();
>         ksession.setGlobal( "list", list );
>         ksession.insert( "mario.fusco at test.org" );
>         ksession.fireAllRules();
>         assertEquals( 1, list.size() );
>         assertEquals( "mario.fusco at test.org", list.get(0) );
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


More information about the jboss-jira mailing list