From b8d0afd977d1b8a40b5d9c8e4f28df35cf3133e2 Mon Sep 17 00:00:00 2001 From: Haotian Zhang <928016560@qq.com> Date: Mon, 6 Mar 2023 16:12:10 +0800 Subject: [PATCH] fix:fix NPE. (#883) --- CHANGELOG.md | 1 + .../feign/DefaultEnhancedFeignPluginRunner.java | 14 ++++---------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ba2c8459..8f5e2102c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) 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)); } }