fix:fix NPE. (#883)

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

@ -13,3 +13,4 @@
- [docs:support auto snapshot release in GitHub Action.](https://github.com/Tencent/spring-cloud-tencent/pull/868)
- [feature:add polaris circuit breaker support.](https://github.com/Tencent/spring-cloud-tencent/pull/875)
- [refactor:refactor stat module.](https://github.com/Tencent/spring-cloud-tencent/pull/876)
- [fix:fix NPE.](https://github.com/Tencent/spring-cloud-tencent/pull/883)

@ -18,12 +18,11 @@
package com.tencent.cloud.rpc.enhancement.feign;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
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.EnhancedFeignPlugin;
import com.tencent.cloud.rpc.enhancement.feign.plugin.EnhancedFeignPluginType;
@ -37,18 +36,13 @@ import org.springframework.util.CollectionUtils;
*/
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) {
if (!CollectionUtils.isEmpty(enhancedFeignPlugins)) {
enhancedFeignPlugins.stream()
.sorted(Comparator.comparing(EnhancedFeignPlugin::getOrder))
.forEach(plugin -> {
if (!pluginMap.containsKey(plugin.getType().name())) {
pluginMap.put(plugin.getType().name(), new ArrayList<>());
}
pluginMap.get(plugin.getType().name()).add(plugin);
});
.forEach(plugin -> pluginMap.put(plugin.getType().name(), plugin));
}
}

Loading…
Cancel
Save