You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2021/09/08 06:03:42 UTC
[dubbo] branch 3.0 updated: [3.0] Enhance: Remove similar code
(#8671)
This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.0 by this push:
new 2b204a1 [3.0] Enhance: Remove similar code (#8671)
2b204a1 is described below
commit 2b204a18eadaee631cef5b66646e11b3883ba1e1
Author: Wang Chengming <63...@qq.com>
AuthorDate: Wed Sep 8 14:03:27 2021 +0800
[3.0] Enhance: Remove similar code (#8671)
* enhance: Remove similar code
* enhance: Remove similar code
---
.../nacos/util/NacosNamingServiceUtils.java | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
diff --git a/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/util/NacosNamingServiceUtils.java b/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/util/NacosNamingServiceUtils.java
index 5ebe4ca..3fc8712 100644
--- a/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/util/NacosNamingServiceUtils.java
+++ b/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/util/NacosNamingServiceUtils.java
@@ -118,13 +118,13 @@ public class NacosNamingServiceUtils {
private static void setServerAddr(URL url, Properties properties) {
StringBuilder serverAddrBuilder =
- new StringBuilder(url.getHost()) // Host
- .append(':')
- .append(url.getPort()); // Port
+ new StringBuilder(url.getHost()) // Host
+ .append(':')
+ .append(url.getPort()); // Port
// Append backup parameter as other servers
String backup = url.getParameter(BACKUP_KEY);
- if (backup != null) {
+ if (StringUtils.isNotEmpty(backup)) {
serverAddrBuilder.append(',').append(backup);
}
@@ -133,7 +133,7 @@ public class NacosNamingServiceUtils {
}
private static void setProperties(URL url, Properties properties) {
- putPropertyIfAbsent(url, properties, NACOS_NAMING_LOG_NAME);
+ putPropertyIfAbsent(url, properties, NACOS_NAMING_LOG_NAME, null);
// @since 2.7.8 : Refactoring
// Get the parameters from constants
@@ -144,19 +144,15 @@ public class NacosNamingServiceUtils {
putPropertyIfAbsent(url, properties, NAMING_LOAD_CACHE_AT_START, "true");
}
- private static void putPropertyIfAbsent(URL url, Properties properties, String propertyName) {
- String propertyValue = url.getParameter(propertyName);
- if (StringUtils.isNotEmpty(propertyValue)) {
- properties.setProperty(propertyName, propertyValue);
- }
- }
-
private static void putPropertyIfAbsent(URL url, Properties properties, String propertyName, String defaultValue) {
String propertyValue = url.getParameter(propertyName);
if (StringUtils.isNotEmpty(propertyValue)) {
properties.setProperty(propertyName, propertyValue);
} else {
- properties.setProperty(propertyName, defaultValue);
+ // when defaultValue is empty, we should not set empty value
+ if (StringUtils.isNotEmpty(defaultValue)) {
+ properties.setProperty(propertyName, defaultValue);
+ }
}
}
}