Bug 1020795 - Extending events doesn't allow to have smaller @expires
Summary: Extending events doesn't allow to have smaller @expires
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: JBoss BRMS Platform 6
Classification: Retired
Component: BRE
Version: 6.0.0
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ---
: ---
Assignee: Edson Tirelli
QA Contact: Lukáš Petrovický
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-10-18 09:46 UTC by Richard Bourner
Modified: 2014-02-10 00:12 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-10-18 13:09:22 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

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.


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