zhaozw opened a new issue, #3165:
URL: https://github.com/apache/servicecomb-java-chassis/issues/3165

   、、、
   
     public <T extends AbstractPolicy> T match(GovernanceRequest request, 
Map<String, T> policies) {
       Map<String, Boolean> calculatedMatches = 
invocationContext.getCalculatedMatches();
   
       List<T> sortPolicies = new ArrayList<>(policies.size());
       sortPolicies.addAll(policies.values());
       sortPolicies.sort(T::compareTo);
   
       for (T policy : sortPolicies) {
         if (calculatedMatches.containsKey(policy.getName())) {
           return policy;
         }
   
         boolean keyMatch = matchersService.checkMatch(request, 
policy.getName());
         invocationContext.addMatch(policy.getName(), keyMatch);
         if (keyMatch) {
           return policy;
         }
       }
       return null;
     }
   、、、
   
针对同一类型的配置policies的值是不变的,但是request可以是不同的,但是如果所有的policy都加入calculatedMatches缓存之后,calculatedMatches.containsKey(policy.getName())一直是true,也就是每次都会返回第一个policy,无论路径是什么,建议加一个url
 + policytype到policy的映射,或者calculatedMatches 的可以由url和policy.getName()拼接的,或者其它好的办法


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