Auditor not set on rules when RuleBookBuilder.create(Class) is used
danielmustafa opened this issue · 2 comments
Suppose I have a class
public class MyRuleBook extends CoRRuleBook {
// some named rules here
}
And I want to reference that class in the RuleBookBuilder process:
RuleBookBuilder.create(MyRuleBook.class).asAuditor().build();
When I use the above statement, the rules inside of MyRuleBook
do not get the Auditor value injected. So when I try to run the rules set I get an NPE in AuditableRule#invoke (Line 100) because it tries to update the RuleStatus but has no Auditor instance to update.
If I try to build a RuleBook using the RuleBookBuilder and use the addRule
chained approach as described in the documentation, it works. Is this Auditor not available when we try to create a rulebook using a specific RuleBook class?
Looking a bit deeper, I believe this is due to the fact that my class rulebook is extending CoRRuleBook, so when the rules are lazily added to the rulebook it is executing the CoRRuleBook#addRule instead of RuleBookAuditor#addRule. However my custom Rulebook does get decorated with RuleBookAuditor like I expect.
I have the same problem and I couldn't fix it.
Did you find a way to solve it ?