[
http://jira.jboss.com/jira/browse/JBRULES-593?page=all ]
Edson Tirelli closed JBRULES-593.
---------------------------------
Resolution: Done
Fixed. Packages now validate that only rules belonging to the same package can be added
and raises an exception otherwise.
Also, rules with the same name being added to the same package will replace older rules,
keeping consistency and allowing for rule updates.
Thank you for reporting and let us know please if you face any other problem on this.
Rule names must be globally unique, even if they come from different
packages
-----------------------------------------------------------------------------
Key: JBRULES-593
URL:
http://jira.jboss.com/jira/browse/JBRULES-593
Project: JBoss Rules
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: Drl Parser/Builder
Affects Versions: 3.0.5
Environment: NA
Reporter: Jeff Lansing
Assigned To: Edson Tirelli
Fix For: 4.0.0.MR4
When 2 DRL rule files with different package names (the name following the
'package' keyword) each have a rule with the same name (the name being the quoted
string that follows the 'rule' keyword), then the following exception occurs:
org.drools.rule.InvalidRulePackage: Rule Compilation error The type
Rule_Incident__Vehicle_0 is already defined
at org.drools.rule.Package.checkValidity(Unknown Source)
at org.drools.common.AbstractRuleBase.addPackage(Unknown Source)
at driver.RulesTest.readRule(RulesTest.java:256)
This occurs when using a single org.drools.rule.Package object, as in:
private void test(Reader source1, Reader source2) throws Exception {
PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( source1 );
builder.addPackageFromDrl( source2 );
Package pkg = builder.getPackage();
RuleBase ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage( pkg );
}
If, on the other hand two org.drools.rule.Package objects are used, as in:
private void test2(Reader source1, Reader source2) throws Exception {
PackageBuilder builder1 = new PackageBuilder();
PackageBuilder builder2 = new PackageBuilder();
builder1.addPackageFromDrl( source1 );
builder2.addPackageFromDrl( source2 );
Package pkg1 = builder1.getPackage();
Package pkg2 = builder2.getPackage();
RuleBase ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage( pkg1 );
ruleBase.addPackage( pkg2 );
}
then one of the identically named rules is simply ignored.
In either case, rule names must be globally unique.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira