Fix conflict

This commit is contained in:
nkorange 2018-11-16 20:33:05 +08:00
parent 93246b3ded
commit c7100e25f8
2 changed files with 6 additions and 7 deletions

View File

@ -28,17 +28,16 @@ import static com.alibaba.nacos.common.util.SystemUtils.PREFER_HOSTNAME_OVER_IP;
*/
public class NetUtils {
private static String localIpAddress = null;
private static String serverAddress = null;
public static String localIP() {
public static String localServer() {
try {
if (StringUtils.isBlank(localIpAddress)) {
localIpAddress = InetAddress.getLocalHost().getHostAddress();
if (StringUtils.isNotBlank(serverAddress)) {
return serverAddress + UtilsAndCommons.CLUSTER_CONF_IP_SPLITER + RunningConfig.getServerPort();
}
return localIpAddress + ":" + RunningConfig.getServerPort();
InetAddress inetAddress = InetAddress.getLocalHost();
String serverAddress = inetAddress.getHostAddress();
serverAddress = inetAddress.getHostAddress();
if (PREFER_HOSTNAME_OVER_IP) {
if (inetAddress.getHostName().equals(inetAddress.getCanonicalHostName())) {
serverAddress = inetAddress.getHostName();

View File

@ -973,7 +973,7 @@ public class ApiCommands {
if (RaftCore.isLeader()) {
try {
domainsManager.getDom2LockMap().get(dom).lock();
proxyParams.put("clientIP", NetUtils.localIP());
proxyParams.put("clientIP", NetUtils.localServer());
proxyParams.put("notify", "true");
proxyParams.put("term", String.valueOf(RaftCore.getPeerSet().local().term));