[jboss-jira] [JBoss JIRA] Reopened: (JBRULES-3052) CCE when using variable bound to accumulate function in RHS code
Wolfgang Laun (JIRA)
jira-events at lists.jboss.org
Fri May 27 05:11:00 EDT 2011
[ https://issues.jboss.org/browse/JBRULES-3052?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Wolfgang Laun reopened JBRULES-3052:
------------------------------------
Still occurs with upstream HEAD compiled at 27-May-2011 10:00 UTC, for instance:
rule "ocount"
when
accumulate( Object(), $c: count(1) )
then
System.out.println( $c + " facts" );
end
> CCE when using variable bound to accumulate function in RHS code
> ----------------------------------------------------------------
>
> Key: JBRULES-3052
> URL: https://issues.jboss.org/browse/JBRULES-3052
> Project: Drools
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: drools-compiler (expert)
> Affects Versions: 5.2.0.M2
> Reporter: Wolfgang Laun
> Assignee: Edson Tirelli
> Fix For: 5.2.0.CR1
>
>
> The rule in the test case crashes during execution with
> java.lang.ClassCastException: java.lang.Double cannot be cast to [Ljava.lang.Object;
> at org.drools.base.extractors.ArrayElementReader.getValue(ArrayElementReader.java:162)
> at org.drools.rule.Declaration.getValue(Declaration.java:219)
> This is meant to be part of AccumulateTest.java.
> public void execTestAccumulateMinMax() throws Exception {
> String drl = "package org.drools.test; " +
> "import org.drools.Cheese; " +
> "global java.util.List results; " +
> "rule minMax " +
> "when " +
> "$min1: Number( $min2: intValue ) " +
> "from accumulate( Cheese( $p: price ), $min3: min($p), $max: max($p) ) " +
> "then " +
> "results.add($min1); results.add($min2); results.add($min3); results.add($max); " +
> "end ";
>
> final Reader reader = new StringReader( drl );
> final RuleBase ruleBase = loadRuleBase( reader );
> final WorkingMemory wm = ruleBase.newStatefulSession();
> final List results = new ArrayList();
> wm.setGlobal( "results", results );
> final Cheese[] cheese = new Cheese[]{
> new Cheese( "Emmentaler", 4 ),
> new Cheese( "Appenzeller", 6 ),
> new Cheese( "Greyerzer", 2 ),
> new Cheese( "Raclette", 3 ),
> new Cheese( "Olmützer Quargel", 15 ),
> new Cheese( "Brie", 17 ),
> new Cheese( "Dolcelatte", 8 ) };
> final FactHandle[] cheeseHandles = new FactHandle[cheese.length];
> for ( int i = 0; i < cheese.length; i++ ) {
> cheeseHandles[i] = wm.insert( cheese[i] );
> }
> // ---------------- 1st scenario
> wm.fireAllRules();
> assertEquals( 4, results.size() );
> assertEquals( results.get(0), Integer.valueOf( 2 ) );
> assertEquals( results.get(1), Integer.valueOf( 2 ) );
> assertEquals( results.get(2), Integer.valueOf( 2 ) );
> assertEquals( results.get(3), Integer.valueOf( 17 ) );
> }
>
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list