[jboss-jira] [JBoss JIRA] Commented: (JBRULES-2140) Function + MVEL dialect == rule firing in error
Edson Tirelli (JIRA)
jira-events at lists.jboss.org
Thu Jun 25 15:29:56 EDT 2009
[ https://jira.jboss.org/jira/browse/JBRULES-2140?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12473822#action_12473822 ]
Edson Tirelli commented on JBRULES-2140:
----------------------------------------
Ok, I found the problem. It was a classloader problem.
What happens is that generated types (like SomeBean in the example) are stored in the JavaDialectRuntimeData.
When the package is added to a knowledgebase, the engine wires all types and classloaders to the respective classloaders used by the knowledgebase. So, the mvel consequence of the rule is wired against the java dialect classloader and everything works.
Now, the presence of a function in the package forces a rewiring on the dialect data. Unfortunately, the re-wiring requires that a new classloader is created for the java dialect. By a hashcode coincidence, the re-wiring happens first on the mvel dialect and later on the java dialect. So, while the java dialect is using a new classloader, the mvel dialect was still referencing the old classloader. So the bean class in the mvel consequence was still using the old classloader, and not matching anything else in the rulebase.
Anyway, to fix this, since Java is our main dialect, I fixed the order of the rewiring to always be: java first, and then all other dialects.
I am running a full build now and will commit right after that.
Thanks for reporting and providing test case.
> Function + MVEL dialect == rule firing in error
> -----------------------------------------------
>
> Key: JBRULES-2140
> URL: https://jira.jboss.org/jira/browse/JBRULES-2140
> Project: JBoss Drools
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: drools-compiler, drools-core
> Affects Versions: 5.0.1.FINAL
> Reporter: Edson Tirelli
> Assignee: Edson Tirelli
> Fix For: 5.1.0.M1
>
>
> REPORTED BY MICHAL:
> ---------------------------------------
> Hi,
> I've encountered a bizarre bug when a function is used together with a declared type and a rule with mvel dialect.
> To reproduce create a default 'New Drools Project' in Eclipse and replace Sample.drl with the following:
> --------------------------------------------------------------------------
> package com.sample
>
> function void aaa() { // <----- comment this and it will work
> }
> declare SomeBean
> prop : int
> end
>
> rule "setup"
> dialect "mvel" // <----- comment this and it will work
> when
> eval(true)
> then
> SomeBean someBean = new SomeBean();
> insert(someBean);
> System.out.println( "setup inserted:" + someBean);
> end
> rule "should never fire"
> salience -20
> when
> not SomeBean()
> then
> System.out.println( "rule that should never fire fired !!!" );
> end
> ------------------------------------------------------------------------
> Run the DroolsTest.java and see that the last rule that should never fire is actually fired. If you comment out the 'aaa' function or change the dialect to 'java' all works fine.
> Note that it breaks on JDK 1.5.0_12 however it works fine on JDK 1.6.0_14.
> Tested on WinXP.
> Is it just my machine or does anybody else see this issue?
> Best regards,
> Michal
--
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