Re: [I] NPE with bound variables used in "not" rule condition element [incubator-kie-drools]

2025-12-24 Thread via GitHub


nagarajgond closed issue #6543: NPE with bound variables used in "not" rule 
condition element
URL: https://github.com/apache/incubator-kie-drools/issues/6543


-- 
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]



Re: [I] NPE with bound variables used in "not" rule condition element [incubator-kie-drools]

2025-12-12 Thread via GitHub


nagarajgond commented on issue #6543:
URL: 
https://github.com/apache/incubator-kie-drools/issues/6543#issuecomment-3645661202

   Thank you for your advice. I used the `not` condition to check whether a 
fact exists in the working memory. I believe I can also use `!= ` for such 
conditions.


-- 
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]



Re: [I] NPE with bound variables used in "not" rule condition element [incubator-kie-drools]

2025-12-11 Thread via GitHub


tkobayas commented on issue #6543:
URL: 
https://github.com/apache/incubator-kie-drools/issues/6543#issuecomment-3645033652

   Yes, a bind variable `$f` with `not` doesn't work.
   
   > Can I solve it like this, is there any performance impact with approach ?
   
   From performance perspective, changing from `update` to `insert`/`add` would 
be small or negligible.
   
   > Any other rule gets impacted by this fact?
   
   I cannot tell the semantic impact, because I don't know your rules.
   
   One advice is to use "Control Fact" for such `preprocess1` flags.
   
   ```
   public class ControlFact {
  private boolean preprocess1;
  ...
   }
   ```
   ```
   rule "rule5_preprocess1"
 when
   ...
 then
   ControlFact controlFact = new ControlFact();
   controlFact.setPreprocess1(true);
   controlFacts.add(controlFact);
   end
   
   rule "rule2"
 when
   ...
   /controlFacts [ preprocess1 == true, preprocess2 == true, preprocess3 == 
true, preprocess4 == true ]
   ...
   /facts...
   ```
   
   It makes clear that ControlFact is used for rule control purpose and is not 
related to business domain.
   
   Btw, it looks odd to me that you mix `/facts` and `not /facts` in one rule, 
because `/facts` matches one fact and `not /facts` matches when "checking all 
facts in working memory and there is no fact which meets the condition". Is it 
intentional? Can't you replace `not /facts[ name == "location.city" ]` with 
`/facts[ name != "location.city" ]"`?


-- 
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]



Re: [I] NPE with bound variables used in "not" rule condition element [incubator-kie-drools]

2025-12-11 Thread via GitHub


nagarajgond commented on issue #6543:
URL: 
https://github.com/apache/incubator-kie-drools/issues/6543#issuecomment-3642681752

   Got it.
   
   If you use an `or` condition where a variable (like $f) is only bound in 
some branches (not all), Drools tries to resolve $f for the then block 
regardless of which branch matched. If the `not` branch matches, $f is not 
bound, leading to a NullPointerException during rule evaluation
   
   So I have to avoid variables for my use case where I use `not` condition as 
well.
   
   Can I solve it like this, is there any performance impact with approach ? 
   
   Any other rule gets impacted by this fact?
   
   ```
   rule "rule5_preprocess1"
salience -997
when
 (/facts [ name == "address", value == "1.1.1.1" ])
 or ( not /facts [ name == "location.city" ] )
or ( /facts [ name == "address", value == "1.1.1.2"])
then
DroolsFact fact = new DroolsFact();
fact.setPreprocess1(true);
facts.add(fact);
System.out.println("rule5_preprocess1 fired");
   end
   ```
   
   @tkobayas - need your suggestions please.


-- 
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]