Bug 1020795

Summary: Extending events doesn't allow to have smaller @expires
Product: [Retired] JBoss BRMS Platform 6 Reporter: Richard Bourner <rbourner>
Component: BREAssignee: Edson Tirelli <etirelli>
Status: CLOSED NOTABUG QA Contact: Lukáš Petrovický <lpetrovi>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.0.0CC: ddoyle, omikelad, rbourner
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-10-18 13:09:22 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Richard Bourner 2013-10-18 09:46:56 UTC
Description of problem:
When extending an event (either in Java or as declarative), if the extended event has a @expires value smaller than its parent, then it is ignored and the parents @expires values is taken.

Example:
declare SimpleEvent
    @role( event ) 
    @timestamp( eventDate.getTime() ) 
    @expires( 2d ) 
end 

declare AvalancheEvent extends SimpleEvent 
    @role( event ) 
    @timestamp( eventDate.getTime() ) 
    @expires( 5m ) 
end 

The reason is in the following class: org.drools.core.reteoo.builder.PatternBuilder.

private static long getExpiratioOffsetForType(BuildContext context, 
                                                  ObjectType objectType) { 
   long expirationOffset = -1; 
   for ( TypeDeclaration type : context.getRuleBase().getTypeDeclarations() ) { 
       if ( type.getObjectType().isAssignableFrom( objectType ) ) { 
           expirationOffset = Math.max( type.getExpirationOffset(), 
                                        expirationOffset ); 
       } 
   } 
   // if none of the type declarations have an @expires annotation 
   // we return -1 (no-expiration) value, otherwise we return the 
   // set expiration value+1 to enable the fact to match events with 
   // the same timestamp 
   return expirationOffset == -1 ? -1 : expirationOffset+1; 
} 

It seems like we can only extends an event if the @expires value is greater than its parent.


Version-Release number of selected component (if applicable):
Drools 6.0.0.CR5

How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 2 Edson Tirelli 2013-10-18 13:09:22 UTC
Richard, this works as designed. The reason is that if you have a rule that uses the parent type, it still has to match the derived type. E.g.:

rule X
when
    ...
    SimpleEvent(...)
    ...
then
...
end

Because of such situations, the expiration offset of an event is always the max between the individual expiration offsets in each rule.

Please note that the global expiration offset for a given type discards the event from the session, but any constraints that would reduce the matching temporal interval are still applied to each rule.