fix:fix NPE. (#886)

pull/888/head
Haotian Zhang 2 years ago committed by GitHub
parent 112a80c45a
commit b3aa093eb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -14,3 +14,4 @@
- [optimize:optimize ServiceRuleManager.](https://github.com/Tencent/spring-cloud-tencent/pull/877) - [optimize:optimize ServiceRuleManager.](https://github.com/Tencent/spring-cloud-tencent/pull/877)
- [refactor:refactor stat module.](https://github.com/Tencent/spring-cloud-tencent/pull/880) - [refactor:refactor stat module.](https://github.com/Tencent/spring-cloud-tencent/pull/880)
- [feature:add polaris circuit breaker support.](https://github.com/Tencent/spring-cloud-tencent/pull/882) - [feature:add polaris circuit breaker support.](https://github.com/Tencent/spring-cloud-tencent/pull/882)
- [fix:fix NPE.](https://github.com/Tencent/spring-cloud-tencent/pull/886)

@ -18,12 +18,11 @@
package com.tencent.cloud.rpc.enhancement.feign; package com.tencent.cloud.rpc.enhancement.feign;
import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import com.tencent.cloud.rpc.enhancement.feign.plugin.EnhancedFeignContext; import com.tencent.cloud.rpc.enhancement.feign.plugin.EnhancedFeignContext;
import com.tencent.cloud.rpc.enhancement.feign.plugin.EnhancedFeignPlugin; import com.tencent.cloud.rpc.enhancement.feign.plugin.EnhancedFeignPlugin;
import com.tencent.cloud.rpc.enhancement.feign.plugin.EnhancedFeignPluginType; import com.tencent.cloud.rpc.enhancement.feign.plugin.EnhancedFeignPluginType;
@ -37,18 +36,13 @@ import org.springframework.util.CollectionUtils;
*/ */
public class DefaultEnhancedFeignPluginRunner implements EnhancedFeignPluginRunner { public class DefaultEnhancedFeignPluginRunner implements EnhancedFeignPluginRunner {
private Map<String, List<EnhancedFeignPlugin>> pluginMap = new HashMap<>(); private final Multimap<String, EnhancedFeignPlugin> pluginMap = ArrayListMultimap.create();
public DefaultEnhancedFeignPluginRunner(List<EnhancedFeignPlugin> enhancedFeignPlugins) { public DefaultEnhancedFeignPluginRunner(List<EnhancedFeignPlugin> enhancedFeignPlugins) {
if (!CollectionUtils.isEmpty(enhancedFeignPlugins)) { if (!CollectionUtils.isEmpty(enhancedFeignPlugins)) {
enhancedFeignPlugins.stream() enhancedFeignPlugins.stream()
.sorted(Comparator.comparing(EnhancedFeignPlugin::getOrder)) .sorted(Comparator.comparing(EnhancedFeignPlugin::getOrder))
.forEach(plugin -> { .forEach(plugin -> pluginMap.put(plugin.getType().name(), plugin));
if (!pluginMap.containsKey(plugin.getType().name())) {
pluginMap.put(plugin.getType().name(), new ArrayList<>());
}
pluginMap.get(plugin.getType().name()).add(plugin);
});
} }
} }

Loading…
Cancel
Save