Bug 869967 - Fact metadata declared in a POJO are lost when declaring fact metadata in DRL
Fact metadata declared in a POJO are lost when declaring fact metadata in DRL
Status: VERIFIED
Product: JBoss Enterprise BRMS Platform 5
Classification: JBoss
Component: BRE (Expert, Fusion) (Show other bugs)
BRMS 5.3.1
Unspecified Unspecified
unspecified Severity medium
: ER4
: BRMS 5.3.1 GA
Assigned To: Mario Fusco
Marek Winkler
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-10-25 05:10 EDT by Marek Winkler
Modified: 2013-10-10 20:07 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
When a POJO had annotations both in the Java class and in the corresponding DRL declared type, only the annotations in the DRL were taken into account. As a result, annotations on the POJO were lost. This has been resolved by merging annotations on both the POJO and the declared type. It is now possible to use annotations in both the POJO and the corresponding declared type.
Story Points: ---
Clone Of:
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
JBoss Issue Tracker JBRULES-3673 Major Resolved Fact metadata declared in a POJO are lost when declaring fact metadata in DRL 2016-02-09 21:39 EST

  None (edit)
Description Marek Winkler 2012-10-25 05:10:39 EDT
Assume a POJO is used as a fact and annotated with @Position as follows:

public class PositionAnnotatedEvent {

  @Position(1)
  private String arg1;

  @Position(0)
  private String arg0;

  // getters and setters
}

When I add some metadata to this class in DRL, for example:

declare org.jboss.qa.brms.bre.regression.POJOAnnotationMergeTest.PositionAnnotatedEvent
    @role(event)
end 

Then the following rule using positional arguments does not compile, producing an IndexOutOfBoundsException with message 'Error trying to access field at position 0'. The same rule with named arguments compiles:

rule 'sample rule' 
when 
  org.jboss.qa.brms.bre.regression.POJOAnnotationMergeTest.PositionAnnotatedEvent( 'value1', 'value2'; ) 
then
end 

The relevant stack trace follows:

java.lang.IndexOutOfBoundsException: Error trying to access field at position 0
	at org.drools.factmodel.ClassDefinition.getField(ClassDefinition.java:162)
	at org.drools.rule.builder.PatternBuilder.processPositional(PatternBuilder.java:432)
	at org.drools.rule.builder.PatternBuilder.processConstraintsAndBinds(PatternBuilder.java:392)
	at org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:310)
	at org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:131)
	at org.drools.rule.builder.GroupElementBuilder.build(GroupElementBuilder.java:65)
	at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:80)
	at org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:2578)
	at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:970)
	at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:456)
	at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:643)
	at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:41)


I will attach a link to pull request with a test case shortly.


Version-Release number of selected component (if applicable):

Tested on BRMS version 5.3.1.BRMS-ER3, the same problem occurs in Drools 6.0.0-SNAPSHOT.


How reproducible:

Will attach a link to pull request shortly.
Comment 1 Marek Winkler 2012-10-25 05:42:31 EDT
The reproducer test case can be found in pull request: https://github.com/droolsjbpm/drools/pull/154
Comment 2 JBoss JIRA Server 2012-10-29 11:15:03 EDT
Mario Fusco <mario.fusco@gmail.com> updated the status of jira JBRULES-3673 to Resolved
Comment 3 Mario Fusco 2012-10-29 11:18:53 EDT
I fixed the issue on the master with this commit:

https://github.com/droolsjbpm/drools/commit/63dfb78c42122dcd6c695e5fb8ed845093d2872a

I am ready to backport this fix to the 5.3.1 as soon as the ack flags will be set.
Comment 5 Mario Fusco 2012-10-31 07:31:26 EDT
Backported to 5.3.1
Comment 6 Marek Winkler 2012-11-12 03:25:30 EST
Verified on 5.3.1.BRMS-ER4

Note You need to log in before you can comment on or make changes to this bug.