Fix URL issue (#13807)
This commit is contained in:
parent
8fb22934d1
commit
860ad02e1e
|
|
@ -339,7 +339,7 @@ public /*final**/ class URL implements Serializable {
|
|||
}
|
||||
|
||||
static String appendDefaultPort(String address, int defaultPort) {
|
||||
if (address != null && address.length() > 0 && defaultPort > 0) {
|
||||
if (StringUtils.isNotEmpty(address) && defaultPort > 0) {
|
||||
int i = address.indexOf(':');
|
||||
if (i < 0) {
|
||||
return address + ":" + defaultPort;
|
||||
|
|
@ -525,7 +525,7 @@ public /*final**/ class URL implements Serializable {
|
|||
List<URL> urls = new ArrayList<>();
|
||||
urls.add(this);
|
||||
String[] backups = getParameter(RemotingConstants.BACKUP_KEY, new String[0]);
|
||||
if (backups != null && backups.length > 0) {
|
||||
if (ArrayUtils.isNotEmpty(backups)) {
|
||||
for (String backup : backups) {
|
||||
urls.add(this.setAddress(backup));
|
||||
}
|
||||
|
|
@ -805,7 +805,7 @@ public /*final**/ class URL implements Serializable {
|
|||
|
||||
public boolean hasParameter(String key) {
|
||||
String value = getParameter(key);
|
||||
return value != null && value.length() > 0;
|
||||
return StringUtils.isNotEmpty(value);
|
||||
}
|
||||
|
||||
public String getMethodParameterAndDecoded(String method, String key) {
|
||||
|
|
@ -1061,7 +1061,7 @@ public /*final**/ class URL implements Serializable {
|
|||
}
|
||||
|
||||
public URL addParameters(String... pairs) {
|
||||
if (pairs == null || pairs.length == 0) {
|
||||
if (ArrayUtils.isEmpty(pairs)) {
|
||||
return this;
|
||||
}
|
||||
if (pairs.length % 2 != 0) {
|
||||
|
|
@ -1589,9 +1589,9 @@ public /*final**/ class URL implements Serializable {
|
|||
return attributes == null ? Collections.emptyMap() : attributes;
|
||||
}
|
||||
|
||||
public URL addAttributes(Map<String, Object> attributes) {
|
||||
if (attributes != null) {
|
||||
attributes.putAll(attributes);
|
||||
public URL addAttributes(Map<String, Object> attributeMap) {
|
||||
if (attributeMap != null) {
|
||||
attributes.putAll(attributeMap);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
|
@ -1718,7 +1718,7 @@ public /*final**/ class URL implements Serializable {
|
|||
|
||||
public boolean hasServiceParameter(String service, String key) {
|
||||
String value = getServiceParameter(service, key);
|
||||
return value != null && value.length() > 0;
|
||||
return StringUtils.isNotEmpty(value);
|
||||
}
|
||||
|
||||
public float getPositiveServiceParameter(String service, String key, float defaultValue) {
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
package org.apache.dubbo.common;
|
||||
|
||||
import org.apache.dubbo.common.url.component.ServiceConfigURL;
|
||||
import org.apache.dubbo.common.utils.ArrayUtils;
|
||||
import org.apache.dubbo.common.utils.CollectionUtils;
|
||||
import org.apache.dubbo.common.utils.StringUtils;
|
||||
import org.apache.dubbo.rpc.model.ScopeModel;
|
||||
|
|
@ -376,7 +377,7 @@ public final class URLBuilder extends ServiceConfigURL {
|
|||
|
||||
@Override
|
||||
public URLBuilder addParameters(String... pairs) {
|
||||
if (pairs == null || pairs.length == 0) {
|
||||
if (ArrayUtils.isEmpty(pairs)) {
|
||||
return this;
|
||||
}
|
||||
if (pairs.length % 2 != 0) {
|
||||
|
|
@ -416,7 +417,7 @@ public final class URLBuilder extends ServiceConfigURL {
|
|||
|
||||
@Override
|
||||
public URLBuilder removeParameters(String... keys) {
|
||||
if (keys == null || keys.length == 0) {
|
||||
if (ArrayUtils.isEmpty(keys)) {
|
||||
return this;
|
||||
}
|
||||
for (String key : keys) {
|
||||
|
|
@ -458,7 +459,7 @@ public final class URLBuilder extends ServiceConfigURL {
|
|||
return false;
|
||||
}
|
||||
String value = getMethodParameter(method, key);
|
||||
return value != null && value.length() > 0;
|
||||
return StringUtils.isNotEmpty(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -113,12 +113,12 @@ public class ServiceConfigURL extends URL {
|
|||
}
|
||||
|
||||
@Override
|
||||
public URL addAttributes(Map<String, Object> attributes) {
|
||||
public URL addAttributes(Map<String, Object> attributeMap) {
|
||||
Map<String, Object> newAttributes = new HashMap<>();
|
||||
if (this.attributes != null) {
|
||||
newAttributes.putAll(this.attributes);
|
||||
}
|
||||
newAttributes.putAll(attributes);
|
||||
newAttributes.putAll(attributeMap);
|
||||
return new ServiceConfigURL(getUrlAddress(), getUrlParam(), newAttributes);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -854,8 +854,8 @@ public class DelegateURL extends com.alibaba.dubbo.common.URL {
|
|||
}
|
||||
|
||||
@Override
|
||||
public org.apache.dubbo.common.URL addAttributes(Map<String, Object> attributes) {
|
||||
return apacheUrl.addAttributes(attributes);
|
||||
public org.apache.dubbo.common.URL addAttributes(Map<String, Object> attributeMap) {
|
||||
return apacheUrl.addAttributes(attributeMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Reference in New Issue