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

[DROOLS-7526] avoid emitting a misleading warning on a contains mvel expression #5449

Merged
merged 1 commit into from
Aug 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 24 additions & 19 deletions drools-mvel/src/main/java/org/drools/mvel/MVELConstraint.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,6 @@

package org.drools.mvel;

import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicInteger;

import org.drools.base.RuleBase;
import org.drools.base.RuleBuildContext;
import org.drools.base.base.DroolsQuery;
Expand Down Expand Up @@ -82,6 +63,25 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicInteger;

import static org.drools.base.reteoo.PropertySpecificUtil.allSetBitMask;
import static org.drools.base.reteoo.PropertySpecificUtil.allSetButTraitBitMask;
import static org.drools.base.reteoo.PropertySpecificUtil.getEmptyPropertyReactiveMask;
Expand Down Expand Up @@ -477,6 +477,11 @@ private BitMask calculateMaskFromExpression(Optional<Pattern> pattern, List<Stri
} else {
// if it is not able to find the property name it could be a function invocation so property reactivity shouldn't filter anything
if (firstProp) {
if (simpleExpression.indexOf(" contains ") > simpleExpression.indexOf(originalPropertyName)) {
// A contains expression could be a rewritten memberOf so give a change also to the part of expression
// after the 'contains' keyword to be analyzed before emitting a warning and consider the constraint as class reactive
continue;
}
if (isBoundVariableFromDifferentPattern(originalPropertyName, pattern)) {
logger.warn("{} is not relevant to this pattern, so it causes class reactivity." +
" Consider placing this constraint in the original pattern if possible : {}",
Expand Down
Loading