Bug 869967 - Fact metadata declared in a POJO are lost when declaring fact metadata in DRL
Summary: Fact metadata declared in a POJO are lost when declaring fact metadata in DRL
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: JBoss Enterprise BRMS Platform 5
Classification: JBoss
Component: BRE (Expert, Fusion)
Version: BRMS 5.3.1
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ER4
: BRMS 5.3.1 GA
Assignee: Mario Fusco
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-10-25 09:10 UTC by Marek Winkler
Modified: 2025-02-10 03:21 UTC (History)
1 user (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2025-02-10 03:21:00 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker JBRULES-3673 0 Major Resolved Fact metadata declared in a POJO are lost when declaring fact metadata in DRL 2016-02-10 02:39:46 UTC

Description Marek Winkler 2012-10-25 09:10:39 UTC
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 09:42:31 UTC
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 15:15:03 UTC
Mario Fusco <mario.fusco> updated the status of jira JBRULES-3673 to Resolved

Comment 3 Mario Fusco 2012-10-29 15:18:53 UTC
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 11:31:26 UTC
Backported to 5.3.1

Comment 6 Marek Winkler 2012-11-12 08:25:30 UTC
Verified on 5.3.1.BRMS-ER4

Comment 13 Red Hat Bugzilla 2025-02-10 03:21:00 UTC
This product has been discontinued or is no longer tracked in Red Hat Bugzilla.


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