[jboss-jira] [JBoss JIRA] (DROOLS-11) ArrayIndexOutOfBoundsException when calling a method with more than two varargs parameters

Mario Fusco (JIRA) jira-events at lists.jboss.org
Tue Jan 22 10:07:21 EST 2013


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

Mario Fusco reassigned DROOLS-11:
---------------------------------

    Assignee: Mario Fusco  (was: Mark Proctor)

    
> ArrayIndexOutOfBoundsException when calling a method with more than two varargs parameters
> ------------------------------------------------------------------------------------------
>
>                 Key: DROOLS-11
>                 URL: https://issues.jboss.org/browse/DROOLS-11
>             Project: Drools
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>            Reporter: Andreas Bentele
>            Assignee: Mario Fusco
>
> I have a rule which uses a Java Interface ILogService with Varargs Parameter. When the rule is evaluated, an ArrayIndexOutOfBoundsException is thrown within MVEL2 code which evaluates the varargs parameters. The MVEL2 code works with two varargs parameters, but not with more than two varargs parameters.
> Drools Version: 5.5.0.Final
> {code}
> // Java Interface ILogService with varargs
> public interface ILogService {
> 	public void debug(String logMessage, Object... arg);
> 	...
> }
> // Global definition ILogService
> global ILogService log;
> rule "..."
> 	ruleflow-group  " ... "
> 	no-loop  true
> 	salience  2
> 	when
>     	...
> 	then
> 		log.debug("{} {} {}", operation.getOrderNumber(), operation.getOperationNumber(), Long.valueOf($operationId));
> end
> {code}
> * Breakpoint in org.mvel2.optimizers.impl.refl.nodes.MethodAccessor.executeAll(Object, VariableResolverFactory, Method), Line 149:
> {code}
> for (int i = 0; i < vararg.length; i++) vararg[i] = parms[parms.length - length + i].getValue(ctx, vars);
> {code}
> * Debugging of this context:
> {code}
> vararg.length = 3
> parms.length = 4
> length = 2
> i = 0 => vararg[0] = parms[4-2+0].getValue(ctx, vars);
> i = 1 => vararg[1] = parms[4-2+1].getValue(ctx, vars);
> i = 2 => vararg[2] = parms[4-2+2].getValue(ctx, vars); => vararg[2] = parms[4].getValue(ctx, vars); => java.lang.ArrayIndexOutOfBoundsException: 4 (because params is an array of length 4 and maximum index 3.
> {code}
> Complete Stacktrace:
> {code}
> MethodAccessor.executeAll(Object, VariableResolverFactory, Method) line: 149	
> MethodAccessor.getValue(Object, Object, VariableResolverFactory) line: 48	
> VariableAccessor.getValue(Object, Object, VariableResolverFactory) line: 37	
> ASTNode.getReducedValueAccelerated(Object, Object, VariableResolverFactory) line: 108	
> MVELRuntime.execute(boolean, CompiledExpression, Object, VariableResolverFactory) line: 85	
> CompiledExpression.getDirectValue(Object, VariableResolverFactory) line: 123	
> CompiledExpression.getValue(Object, VariableResolverFactory) line: 119	
> MVEL.executeExpression(Object, Object, VariableResolverFactory) line: 930	
> MVELConsequence.evaluate(KnowledgeHelper, WorkingMemory) line: 104	
> DefaultAgenda.fireActivation(Activation) line: 1287	
> DefaultAgenda.fireNextItem(AgendaFilter) line: 1221	
> DefaultAgenda.fireAllRules(AgendaFilter, int) line: 1456	
> ReteooStatefulSession(AbstractWorkingMemory).fireAllRules(AgendaFilter, int) line: 710	
> ReteooStatefulSession(AbstractWorkingMemory).fireAllRules() line: 674	
> StatefulKnowledgeSessionImpl.fireAllRules() line: 230	
> ...
> {code}
> I tried to create a simple test case to reproduce it, but the test case always worked - no Exception. but there was also another Stacktrace when stopping at a breakpoint in the LogService:
> {code}
> LogService.info(String, Object...) line: 60	
> Rule_Hello_World_4df945f15bc043ef85d8e1317cd461f1.defaultConsequence(KnowledgeHelper, ILogService) line: 7	
> Rule_Hello_World_4df945f15bc043ef85d8e1317cd461f1DefaultConsequenceInvokerGenerated.evaluate(KnowledgeHelper, WorkingMemory) line: not available	
> Rule_Hello_World_4df945f15bc043ef85d8e1317cd461f1DefaultConsequenceInvoker.evaluate(KnowledgeHelper, WorkingMemory) line: not available	
> DefaultAgenda.fireActivation(Activation) line: 1287	
> DefaultAgenda.fireNextItem(AgendaFilter) line: 1221	
> DefaultAgenda.fireAllRules(AgendaFilter, int) line: 1456	
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the jboss-jira mailing list