Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auditor not set on rules when RuleBookBuilder.create(Class) is used #202

Open
danielmustafa opened this issue Jan 13, 2021 · 2 comments
Open

Comments

@danielmustafa
Copy link

danielmustafa commented Jan 13, 2021

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?

@danielmustafa
Copy link
Author

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.

@rocnwall
Copy link

I have the same problem and I couldn't fix it.
Did you find a way to solve it ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants