fix:fix NPE.

pull/1080/head
Haotian Zhang 2 years ago
parent 9408bfbb94
commit 17a9a8d75a

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