damonxue commented on issue #3906:
URL: https://github.com/apache/shenyu/issues/3906#issuecomment-1235143592

   I think the codes under is u commented, Sure?  With selector and rule, we 
match the best one to execute u logic, so we can change selector and rule to do 
that. Is that right?
   
   ```java
   # @see org.apache.shenyu.plugin.base.AbstractShenyuPlugin;
   private SelectorData manyMatchSelector(final List<SelectorData> 
filterCollectors) {
           //What needs to be dealt with here is the and condition. If the 
number of and conditions is the same and is matched at the same time,
           // it will be sorted by the sort field.
           Map<Integer, List<Pair<Integer, SelectorData>>> collect =
                   filterCollectors.stream().map(selector -> {
                       boolean match = 
MatchModeEnum.match(selector.getMatchMode(), MatchModeEnum.AND);
                       int sort = 0;
                       if (match) {
                           sort = selector.getConditionList().size();
                       }
                       return Pair.of(sort, selector);
                   }).collect(Collectors.groupingBy(Pair::getLeft));
           Integer max = Collections.max(collect.keySet());
           List<Pair<Integer, SelectorData>> pairs = collect.get(max);
           return 
pairs.stream().map(Pair::getRight).min(Comparator.comparing(SelectorData::getSort)).orElse(null);
       }
   ```


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

Reply via email to