Merge branch 'develop' into feature_mcp

This commit is contained in:
Fury Zhu 2019-10-21 16:21:42 +08:00 committed by GitHub
commit fcf62bbd5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
38 changed files with 54 additions and 110 deletions

View File

@ -33,9 +33,9 @@ import com.alibaba.nacos.client.config.impl.LocalConfigInfoProcessor;
import com.alibaba.nacos.client.config.utils.ContentUtils;
import com.alibaba.nacos.client.config.utils.ParamUtils;
import com.alibaba.nacos.client.utils.LogUtils;
import com.alibaba.nacos.client.utils.StringUtils;
import com.alibaba.nacos.client.utils.TemplateUtils;
import com.alibaba.nacos.client.utils.TenantUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import java.io.IOException;

View File

@ -15,7 +15,7 @@
*/
package com.alibaba.nacos.client.config.common;
import com.alibaba.nacos.client.utils.StringUtils;
import org.apache.commons.lang3.StringUtils;
/**
* Synthesize the form of dataId+groupId. Escapes reserved characters in dataId and groupId.

View File

@ -28,9 +28,9 @@ import com.alibaba.nacos.client.utils.TemplateUtils;
import com.alibaba.nacos.client.utils.JSONUtils;
import com.alibaba.nacos.client.utils.LogUtils;
import com.alibaba.nacos.client.utils.ParamUtil;
import com.alibaba.nacos.client.utils.StringUtils;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.slf4j.Logger;
import java.io.IOException;

View File

@ -28,7 +28,7 @@ import com.alibaba.nacos.client.config.utils.MD5;
import com.alibaba.nacos.client.monitor.MetricsMonitor;
import com.alibaba.nacos.client.utils.LogUtils;
import com.alibaba.nacos.client.utils.ParamUtil;
import com.alibaba.nacos.client.utils.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import com.alibaba.nacos.client.utils.TenantUtil;
import org.slf4j.Logger;

View File

@ -21,7 +21,7 @@ import com.alibaba.nacos.client.config.utils.IOUtils;
import com.alibaba.nacos.client.config.utils.JVMUtil;
import com.alibaba.nacos.client.config.utils.SnapShotSwitch;
import com.alibaba.nacos.client.utils.LogUtils;
import com.alibaba.nacos.client.utils.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import java.io.File;

View File

@ -18,7 +18,7 @@ package com.alibaba.nacos.client.config.impl;
import com.alibaba.nacos.api.common.Constants;
import com.alibaba.nacos.client.identify.Base64;
import com.alibaba.nacos.client.identify.CredentialService;
import com.alibaba.nacos.client.utils.StringUtils;
import org.apache.commons.lang3.StringUtils;
import javax.crypto.Mac;
import javax.crypto.SecretKey;

View File

@ -17,7 +17,7 @@ package com.alibaba.nacos.client.config.listener.impl;
import com.alibaba.nacos.api.config.listener.AbstractListener;
import com.alibaba.nacos.client.utils.LogUtils;
import com.alibaba.nacos.client.utils.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import java.io.IOException;

View File

@ -19,7 +19,7 @@ import java.util.List;
import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.client.utils.IPUtil;
import com.alibaba.nacos.client.utils.StringUtils;
import org.apache.commons.lang3.StringUtils;
/**
* Param check util

View File

@ -16,7 +16,7 @@
package com.alibaba.nacos.client.identify;
import com.alibaba.nacos.client.utils.LogUtils;
import com.alibaba.nacos.client.utils.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import java.util.concurrent.ConcurrentHashMap;

View File

@ -16,7 +16,7 @@
package com.alibaba.nacos.client.identify;
import com.alibaba.nacos.client.utils.LogUtils;
import com.alibaba.nacos.client.utils.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import java.io.*;

View File

@ -15,7 +15,7 @@
*/
package com.alibaba.nacos.client.identify;
import com.alibaba.nacos.client.utils.StringUtils;
import org.apache.commons.lang3.StringUtils;
/**
* Sts config

View File

@ -15,8 +15,8 @@
*/
package com.alibaba.nacos.client.logging;
import com.alibaba.nacos.client.utils.StringUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
/**
* @author <a href="mailto:huangxiaoyu1018@gmail.com">hxy1991</a>

View File

@ -18,8 +18,8 @@ package com.alibaba.nacos.client.logging.logback;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.util.ContextInitializer;
import com.alibaba.nacos.client.logging.AbstractNacosLogging;
import com.alibaba.nacos.client.utils.StringUtils;
import com.alibaba.nacos.common.util.ResourceUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.impl.StaticLoggerBinder;
/**

View File

@ -27,7 +27,7 @@ import com.alibaba.nacos.api.selector.ExpressionSelector;
import com.alibaba.nacos.api.selector.NoneSelector;
import com.alibaba.nacos.client.naming.net.NamingProxy;
import com.alibaba.nacos.client.naming.utils.InitUtils;
import com.alibaba.nacos.client.utils.StringUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.Map;
import java.util.Properties;

View File

@ -34,8 +34,8 @@ import com.alibaba.nacos.client.naming.net.NamingProxy;
import com.alibaba.nacos.client.naming.utils.CollectionUtils;
import com.alibaba.nacos.client.naming.utils.InitUtils;
import com.alibaba.nacos.client.naming.utils.UtilAndComs;
import com.alibaba.nacos.client.utils.StringUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import java.util.ArrayList;

View File

@ -22,7 +22,7 @@ import com.alibaba.nacos.client.naming.cache.DiskCache;
import com.alibaba.nacos.client.naming.core.HostReactor;
import com.alibaba.nacos.client.naming.utils.CollectionUtils;
import com.alibaba.nacos.client.naming.utils.UtilAndComs;
import com.alibaba.nacos.client.utils.StringUtils;
import org.apache.commons.lang3.StringUtils;
import java.io.BufferedReader;
import java.io.File;

View File

@ -20,7 +20,7 @@ import com.alibaba.nacos.api.common.Constants;
import com.alibaba.nacos.api.naming.pojo.Instance;
import com.alibaba.nacos.api.naming.pojo.ServiceInfo;
import com.alibaba.nacos.client.naming.utils.CollectionUtils;
import com.alibaba.nacos.client.utils.StringUtils;
import org.apache.commons.lang3.StringUtils;
import java.io.BufferedReader;
import java.io.File;

View File

@ -24,7 +24,7 @@ import com.alibaba.nacos.client.naming.backups.FailoverReactor;
import com.alibaba.nacos.client.naming.cache.DiskCache;
import com.alibaba.nacos.client.naming.net.NamingProxy;
import com.alibaba.nacos.client.naming.utils.UtilAndComs;
import com.alibaba.nacos.client.utils.StringUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.*;
import java.util.concurrent.*;

View File

@ -17,8 +17,8 @@ package com.alibaba.nacos.client.naming.net;
import com.alibaba.nacos.api.common.Constants;
import com.alibaba.nacos.client.naming.utils.IoUtils;
import com.alibaba.nacos.client.utils.StringUtils;
import com.google.common.net.HttpHeaders;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
import java.io.InputStream;

View File

@ -33,12 +33,12 @@ import com.alibaba.nacos.client.monitor.MetricsMonitor;
import com.alibaba.nacos.client.naming.beat.BeatInfo;
import com.alibaba.nacos.client.naming.utils.*;
import com.alibaba.nacos.client.utils.AppNameUtils;
import com.alibaba.nacos.client.utils.StringUtils;
import com.alibaba.nacos.client.utils.TemplateUtils;
import com.alibaba.nacos.common.constant.HttpHeaderConsts;
import com.alibaba.nacos.common.util.HttpMethod;
import com.alibaba.nacos.common.util.UuidUtils;
import com.alibaba.nacos.common.util.VersionUtils;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
import java.io.StringReader;
@ -558,7 +558,7 @@ public class NamingProxy {
this.serverPort = serverPort;
String sp = System.getProperty(SystemPropertyKeyConst.NAMING_SERVER_PORT);
if (com.alibaba.nacos.client.utils.StringUtils.isNotBlank(sp)) {
if (StringUtils.isNotBlank(sp)) {
this.serverPort = Integer.parseInt(sp);
}
}

View File

@ -16,7 +16,7 @@
package com.alibaba.nacos.client.naming.utils;
import com.alibaba.nacos.client.utils.StringUtils;
import org.apache.commons.lang3.StringUtils;
import java.io.*;
import java.nio.channels.FileChannel;

View File

@ -15,7 +15,7 @@
*/
package com.alibaba.nacos.client.naming.utils;
import com.alibaba.nacos.client.utils.StringUtils;
import org.apache.commons.lang3.StringUtils;
import java.net.InetAddress;
import java.net.UnknownHostException;

View File

@ -157,7 +157,7 @@ public class ParamUtil {
|| !PATTERN.matcher(endpointUrl).find()) {
// skip retrieve from system property and retrieve directly from system env
String endpointUrlSource = System.getenv(PropertyKeyConst.SystemEnv.ALIBABA_ALIWARE_ENDPOINT_URL);
if (com.alibaba.nacos.client.utils.StringUtils.isNotBlank(endpointUrlSource)) {
if (StringUtils.isNotBlank(endpointUrlSource)) {
endpointUrl = endpointUrlSource;
}
@ -182,8 +182,8 @@ public class ParamUtil {
});
if (com.alibaba.nacos.client.utils.StringUtils.isBlank(endpointUrlSource)) {
if (com.alibaba.nacos.client.utils.StringUtils.isNotBlank(defaultEndpointUrl)) {
if (StringUtils.isBlank(endpointUrlSource)) {
if (StringUtils.isNotBlank(defaultEndpointUrl)) {
endpointUrl = defaultEndpointUrl;
}
} else {

View File

@ -25,7 +25,9 @@ import java.util.Locale;
* string util
*
* @author Nacos
* @deprecated Use {@link org.apache.commons.lang3.StringUtils} instead
*/
@Deprecated
public class StringUtils {
private static final int INDEX_NOT_FOUND = -1;

View File

@ -9,6 +9,7 @@ import java.util.Collection;
import static org.junit.Assert.*;
import static com.alibaba.nacos.client.utils.StringUtils.*;
@Deprecated
public class StringUtilsTest {
@Test

View File

@ -18,8 +18,8 @@ package com.alibaba.nacos.config.server.service;
import com.alibaba.nacos.config.server.constant.Constants;
import com.alibaba.nacos.config.server.utils.LogUtil;
import com.alibaba.nacos.config.server.utils.PropertyUtil;
import com.alibaba.nacos.config.server.utils.StringUtils;
import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

View File

@ -29,7 +29,7 @@ import com.alibaba.nacos.config.server.service.trace.ConfigTraceService;
import com.alibaba.nacos.config.server.utils.GroupKey2;
import com.alibaba.nacos.config.server.utils.LogUtil;
import com.alibaba.nacos.config.server.utils.MD5;
import com.alibaba.nacos.config.server.utils.StringUtils;
import org.apache.commons.lang3.StringUtils;
import java.sql.Timestamp;
import java.util.List;

View File

@ -25,9 +25,9 @@ import com.alibaba.nacos.config.server.service.ConfigDataChangeEvent;
import com.alibaba.nacos.config.server.service.PersistService;
import com.alibaba.nacos.config.server.service.trace.ConfigTraceService;
import com.alibaba.nacos.config.server.utils.ContentUtils;
import com.alibaba.nacos.config.server.utils.StringUtils;
import com.alibaba.nacos.config.server.utils.TimeUtils;
import com.alibaba.nacos.config.server.utils.event.EventDispatcher;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@ -23,9 +23,9 @@ import com.alibaba.nacos.config.server.service.trace.ConfigTraceService;
import com.alibaba.nacos.config.server.utils.LogUtil;
import com.alibaba.nacos.config.server.utils.PropertyUtil;
import com.alibaba.nacos.config.server.utils.RunningConfigUtils;
import com.alibaba.nacos.config.server.utils.StringUtils;
import com.alibaba.nacos.config.server.utils.event.EventDispatcher.AbstractEventListener;
import com.alibaba.nacos.config.server.utils.event.EventDispatcher.Event;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.config.RequestConfig;

View File

@ -15,6 +15,8 @@
*/
package com.alibaba.nacos.config.server.utils;
import org.apache.commons.lang3.StringUtils;
import java.io.File;
/**

View File

@ -15,6 +15,8 @@
*/
package com.alibaba.nacos.config.server.utils;
import org.apache.commons.lang3.StringUtils;
/**
* 合成dataId+groupId的形式对dataId和groupId中的保留字符做转义
*

View File

@ -15,6 +15,8 @@
*/
package com.alibaba.nacos.config.server.utils;
import org.apache.commons.lang3.StringUtils;
/**
* Group key util
*

View File

@ -15,6 +15,8 @@
*/
package com.alibaba.nacos.config.server.utils;
import org.apache.commons.lang3.StringUtils;
import javax.servlet.http.HttpServletRequest;
/**

View File

@ -1,69 +0,0 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.nacos.config.server.utils;
/**
* 替代common-lang中类减少依赖
*
* @author Nacos
*/
public class StringUtils {
public static final int INDEX_NOT_FOUND = -1;
public static boolean isBlank(String str) {
int strLen;
if (str == null || (strLen = str.length()) == 0) {
return true;
}
for (int i = 0; i < strLen; i++) {
if ((Character.isWhitespace(str.charAt(i)) == false)) {
return false;
}
}
return true;
}
public static boolean isNotEmpty(String str) {
return !StringUtils.isEmpty(str);
}
public static boolean isEmpty(String str) {
return str == null || str.length() == 0;
}
public static String defaultIfEmpty(String str, String defaultStr) {
return StringUtils.isEmpty(str) ? defaultStr : str;
}
public static boolean equals(String str1, String str2) {
return str1 == null ? str2 == null : str1.equals(str2);
}
public static String substringBetween(String str, String open, String close) {
if (str == null || open == null || close == null) {
return null;
}
int start = str.indexOf(open);
if (start != INDEX_NOT_FOUND) {
int end = str.indexOf(close, start + open.length());
if (end != INDEX_NOT_FOUND) {
return str.substring(start + open.length(), end);
}
}
return null;
}
}

View File

@ -19,9 +19,9 @@ import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.config.server.model.RestResult;
import com.alibaba.nacos.config.server.model.TenantInfo;
import com.alibaba.nacos.config.server.service.PersistService;
import com.alibaba.nacos.config.server.utils.StringUtils;
import com.alibaba.nacos.console.model.Namespace;
import com.alibaba.nacos.console.model.NamespaceAllInfo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

View File

@ -445,9 +445,9 @@ public class ServiceManager implements RecordListener<Service> {
service.getClusterMap().put(cluster.getName(), cluster);
}
service.validate();
if (local) {
putServiceAndInit(service);
} else {
if (!local) {
addOrReplaceService(service);
}
}
@ -470,9 +470,9 @@ public class ServiceManager implements RecordListener<Service> {
service.getClusterMap().put(cluster.getName(), cluster);
}
service.validate();
if (local) {
putServiceAndInit(service);
} else {
if (!local) {
addOrReplaceService(service);
}
}

View File

@ -26,6 +26,7 @@ import com.alibaba.nacos.naming.misc.UtilsAndCommons;
import com.alibaba.nacos.naming.pojo.Subscriber;
import com.alibaba.nacos.naming.pojo.Subscribers;
import com.alibaba.nacos.naming.push.PushService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -80,6 +81,7 @@ public class SubscribeManager {
paramValues.put("aggregation", String.valueOf(Boolean.FALSE));
if (NetUtils.localServer().equals(server.getKey())) {
subscriberList.addAll(getSubscribers(serviceName, namespaceId));
continue;
}
HttpClient.HttpResult result = HttpClient.httpGet("http://" + server.getKey() + RunningConfig.getContextPath()
@ -89,14 +91,14 @@ public class SubscribeManager {
Subscribers subscribers = (Subscribers) JSONObject.parseObject(result.content, Subscribers.class);
subscriberList.addAll(subscribers.getSubscribers());
}
return subscriberList.stream().filter(distinctByKey(Subscriber::toString)).collect(Collectors.toList());
}
return CollectionUtils.isNotEmpty(subscriberList) ?
subscriberList.stream().filter(distinctByKey(Subscriber::toString)).collect(Collectors.toList())
: Collections.EMPTY_LIST;
} else {
// local server
return getSubscribers(serviceName, namespaceId);
}
return Collections.emptyList();
}
public static <T> Predicate<T> distinctByKey(Function<? super T, Object> keyExtractor) {

View File

@ -715,7 +715,7 @@
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.1.31.Final</version>
<version>4.1.42.Final</version>
</dependency>
<dependency>