-
Notifications
You must be signed in to change notification settings - Fork 824
Closed
Description
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()拼接的,或者其它好的办法
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels