From b3aa093eb984e31c057493e4aea381d3c668f1b2 Mon Sep 17 00:00:00 2001 From: Haotian Zhang <928016560@qq.com> Date: Mon, 6 Mar 2023 16:11:18 +0800 Subject: [PATCH] fix:fix NPE. (#886) --- CHANGELOG.md | 1 + .../feign/DefaultEnhancedFeignPluginRunner.java | 14 ++++---------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d235e9cee..54a21959e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,3 +14,4 @@ - [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) - [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) diff --git a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/feign/DefaultEnhancedFeignPluginRunner.java b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/feign/DefaultEnhancedFeignPluginRunner.java index affce002a..dbaf7d580 100644 --- a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/feign/DefaultEnhancedFeignPluginRunner.java +++ b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/feign/DefaultEnhancedFeignPluginRunner.java @@ -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> pluginMap = new HashMap<>(); + private final Multimap pluginMap = ArrayListMultimap.create(); public DefaultEnhancedFeignPluginRunner(List 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)); } }