Bug 1020795 - Extending events doesn't allow to have smaller @expires
Extending events doesn't allow to have smaller @expires
Status: CLOSED NOTABUG
Product: JBoss BRMS Platform 6
Classification: JBoss
Component: BRE (Show other bugs)
6.0.0
Unspecified Unspecified
unspecified Severity high
: ---
: ---
Assigned To: Edson Tirelli
Lukáš Petrovický
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-10-18 05:46 EDT by Richard Bourner
Modified: 2014-02-09 19:12 EST (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-10-18 09:09:22 EDT
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)

  None (edit)
Description Richard Bourner 2013-10-18 05:46:56 EDT
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 09:09:22 EDT
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.

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