This is an automated email from the ASF dual-hosted git repository. xiaoyu pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/shenyu.git
The following commit(s) were added to refs/heads/master by this push: new b6f359ac3a [fix:bugfix] readYmlBuildRepository NPE (#5818) (#5819) b6f359ac3a is described below commit b6f359ac3a3b98470d46651cdebeca8495e615cc Author: frank <shaoshuai...@163.com> AuthorDate: Thu Nov 28 18:03:51 2024 +0800 [fix:bugfix] readYmlBuildRepository NPE (#5818) (#5819) --- .../handler/SpringCloudPluginDataHandler.java | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-springcloud/src/main/java/org/apache/shenyu/plugin/springcloud/handler/SpringCloudPluginDataHandler.java b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-springcloud/src/main/java/org/apache/shenyu/plugin/springcloud/handler/SpringCloudPluginDataHandler.java index e8cb2f2798..df3215c613 100644 --- a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-springcloud/src/main/java/org/apache/shenyu/plugin/springcloud/handler/SpringCloudPluginDataHandler.java +++ b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-springcloud/src/main/java/org/apache/shenyu/plugin/springcloud/handler/SpringCloudPluginDataHandler.java @@ -57,9 +57,9 @@ import java.util.stream.Collectors; * The type spring cloud plugin data handler. */ public class SpringCloudPluginDataHandler implements PluginDataHandler { - + public static final Supplier<CommonHandleCache<String, SpringCloudSelectorHandle>> SELECTOR_CACHED = new BeanHolder<>(CommonHandleCache::new); - + public static final Supplier<CommonHandleCache<String, SpringCloudRuleHandle>> RULE_CACHED = new BeanHolder<>(CommonHandleCache::new); private static ShenyuInstanceRegisterRepository repository; @@ -69,7 +69,7 @@ public class SpringCloudPluginDataHandler implements PluginDataHandler { private final ShenyuConfig.SpringCloudCacheConfig springCloudCacheConfig; private final Environment env; - + public SpringCloudPluginDataHandler(final ShenyuConfig.SpringCloudCacheConfig springCloudCacheConfig, final Environment env) { this.springCloudCacheConfig = springCloudCacheConfig; this.env = env; @@ -193,10 +193,18 @@ public class SpringCloudPluginDataHandler implements PluginDataHandler { final String prefix = "spring.cloud.nacos.discovery."; Properties properties = new Properties(); properties.put(PropertyKeyConst.NAMESPACE, env.getProperty(prefix + PropertyKeyConst.NAMESPACE)); - properties.put(PropertyKeyConst.USERNAME, env.getProperty(prefix + PropertyKeyConst.USERNAME)); - properties.put(PropertyKeyConst.PASSWORD, env.getProperty(prefix + PropertyKeyConst.PASSWORD)); - properties.put(PropertyKeyConst.ACCESS_KEY, env.getProperty(prefix + PropertyKeyConst.ACCESS_KEY)); - properties.put(PropertyKeyConst.SECRET_KEY, env.getProperty(prefix + PropertyKeyConst.SECRET_KEY)); + if (env.getProperty(prefix + PropertyKeyConst.USERNAME) != null) { + properties.put(PropertyKeyConst.USERNAME, env.getProperty(prefix + PropertyKeyConst.USERNAME)); + } + if (env.getProperty(prefix + PropertyKeyConst.PASSWORD) != null) { + properties.put(PropertyKeyConst.PASSWORD, env.getProperty(prefix + PropertyKeyConst.PASSWORD)); + } + if (env.getProperty(prefix + PropertyKeyConst.ACCESS_KEY) != null) { + properties.put(PropertyKeyConst.ACCESS_KEY, env.getProperty(prefix + PropertyKeyConst.ACCESS_KEY)); + } + if (env.getProperty(prefix + PropertyKeyConst.SECRET_KEY) != null) { + properties.put(PropertyKeyConst.SECRET_KEY, env.getProperty(prefix + PropertyKeyConst.SECRET_KEY)); + } RegisterConfig registerConfig = RegisterConfig.Builder.builder() .enabled(true) .registerType("nacos")