tomcoh22 opened a new issue, #6420:
URL: https://github.com/apache/incubator-kie-drools/issues/6420

   
[LoanTest.java](https://github.com/user-attachments/files/21781079/LoanTest.java)
   
   
[LoanType.java](https://github.com/user-attachments/files/21781082/LoanType.java)
   [Person.java](https://github.com/user-attachments/files/21781081/Person.java)
   
   
[loan_test.drl.txt](https://github.com/user-attachments/files/21781089/loan_test.drl.txt)
   
   modify or update in DRL causing rules with eval condition to fire 
incorrectly even when other pattern constraints are not matching. This issue 
exists since version 8.33. 
   
   Here is the sample DRL and output. The rules check_additional_liability and 
check_bankruptcy should not have fired because the state is not matching. This 
issue is preventing us from upgrading our rules from 7.74 to newer versions
   
   
   **DRL**
   
   package loan;
   
   import com.mycompany.loan.Person;
   import com.mycompany.loan.LoanType;
   
   function boolean hasAnyOtherLiability(int liability)
   {
       return liability > 0;
   }
   
   //this rule is only for CA, shouldn't fire for NY, OR and FL
   rule check_additional_liability
       no-loop true
       enabled true
       when
           loanType: LoanType(this == LoanType.PERSONAL || this == MORTGAGE)
           person: Person(liability: liability,
                           state == "CA");
           eval(hasAnyOtherLiability(liability));
       then
           System.out.println("Person has additional liability. This rule 
should be fired only if state is CA. Person's state is " + person.getState());
   end
   
   //this rule is only for OR and FL, shouldn't fire for CA or NY
   rule check_bankruptcy
       no-loop true
       enabled true
       when
           loanType: LoanType(this == LoanType.PERSONAL || this == MORTGAGE)
           person: Person(state == "OR" || state == "FL");
           eval(person.getBankruptcy() > 0);
       then
           System.out.println("Person is bankrupt. This rule should be fired 
only if state is OR or FL. Person's state is " + person.getState());
   end
   
   
   rule under_age_loan_denied
       no-loop true
       enabled true
       when
           loanType: LoanType(this == LoanType.PERSONAL || this == MORTGAGE)
           person: Person(age < 21, state == "CA" || state == "NY" || state == 
"NM");
   
       then
           System.out.println("Under age person and loan is denied. This rule 
should be fired if state is CA, NY or NM. Person's state is " + 
person.getState());
   
           modify(person) {
               setLoanApproved(false)
           }
   end
   
   
   rule loan_not_approved
       no-loop true
       enabled true
       when
           loanType: LoanType(this == LoanType.PERSONAL || this == MORTGAGE)
           person: Person(loanApproved == false);
   
       then
           System.out.println("Loan not approved. This rule should fire only if 
loan is denied.");
   end
   
   
   **Output** 
   
   Under age person and loan is denied. This rule should be fired if state is 
CA, NY or NM. Person's state is NY
   Rule fired: under_age_loan_denied
   
   Person has additional liability. This rule should be fired only if state is 
CA. Person's state is NY
   Rule fired: check_additional_liability
   
   Person is bankrupt. This rule should be fired only if state is OR or FL. 
Person's state is NY
   Rule fired: check_bankruptcy
   
   Loan not approved. This rule should fire only if loan is denied.
   Rule fired: loan_not_approved
   
   Number of rules fired: 4
   
   
   
   
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to