[jboss-jira] [JBoss JIRA] Created: (JBRULES-2403) Accumulate with from chaining fails with Rule Compilation Error when reverse is used

hoogenbj (JIRA) jira-events at lists.jboss.org
Tue Jan 12 05:54:31 EST 2010


Accumulate with from chaining fails with Rule Compilation Error when reverse is used
------------------------------------------------------------------------------------

                 Key: JBRULES-2403
                 URL: https://jira.jboss.org/jira/browse/JBRULES-2403
             Project: Drools
          Issue Type: Bug
      Security Level: Public (Everyone can see)
          Components: drools-compiler
    Affects Versions: 5.0.1.FINAL
         Environment: Eclipse Galileo, JDK 1.6 (64-bit), Drools 5.0.1, Vista 64-bit
            Reporter: hoogenbj
            Assignee: Mark Proctor


Hi,
While trying to upgrade from Drools 4.0.7 to Drools 5.0.1 I noticed a problem with the rules that use accumulate-with-from-chaining. 
If there is a reverse action, then I get a Rule Compilation error:

java.lang.RuntimeException: Rule Compilation error : [Rule name='Accumulate with From Chaining']
	org/drools/Rule_Accumulate_with_From_Chaining_0.java (11:62) : File org/drools/Rule_Accumulate_with_From_Chaining_0.java, Line 11, Column 62: Operator "[" expected

	at org.drools.TestKnowledgeBuilder.test(TestKnowledgeBuilder.java:34)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
	at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

It works fine with Drools 4.0.7.
If the "reverse" is removed, then the rule compiles fine. So I guess that is the workaround - but only if you don't need the reverse.
I have an eclipse project that demonstrates the problem but there does not seem to be a way to upload it.
Here's what the rule looks like:

package org.drools;

import java.util.List;
import java.util.ArrayList;

global java.util.List results;

rule "Accumulate with From Chaining" salience 80
    when
        $cheesery : Cheesery()
        $person   : Person( $likes : likes )
    	$list     : List( size > 2 ) 
    	                       from accumulate( $cheese : Cheese( type == $likes  ) from $cheesery.getCheeses(),
                                                init( List l = new ArrayList(); ),
                                                action( l.add( $cheese ); ),
                                                reverse( l.remove( $cheese ); ),
                                                result( l ) )
    then
        results.add( $list );
end  

I modified test_AccumulateWithFromChaining.drl in drools-5.0\src\drools-compiler\src\test\resources\org\drools\integrationtests for my test.

Here is my test code:

    Properties props = new Properties();
    props.setProperty("drools.dialect.java.compiler", "JANINO");
    KnowledgeBuilderConfiguration config = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(props, this.getClass().getClassLoader());
    KnowledgeBuilder knowledgeBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(config);
    knowledgeBuilder.add(ResourceFactory.newInputStreamResource(getClass().getResourceAsStream( "test_AccumulateWithFromChaining.drl" )), ResourceType.DRL);
    if (knowledgeBuilder.hasErrors()) {
      throw new RuntimeException(knowledgeBuilder.getErrors().toString());
    }

which results in a RuntimeException.

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