diff --git a/common/src/main/java/com/alibaba/nacos/common/remote/client/RpcClient.java b/common/src/main/java/com/alibaba/nacos/common/remote/client/RpcClient.java index 01cd63d0e..3674f213e 100644 --- a/common/src/main/java/com/alibaba/nacos/common/remote/client/RpcClient.java +++ b/common/src/main/java/com/alibaba/nacos/common/remote/client/RpcClient.java @@ -68,7 +68,7 @@ public abstract class RpcClient implements Closeable { private ServerListFactory serverListFactory; - protected LinkedBlockingQueue eventLinkedBlockingQueue = new LinkedBlockingQueue<>(); + protected BlockingQueue eventLinkedBlockingQueue = new LinkedBlockingQueue<>(); protected volatile AtomicReference rpcClientStatus = new AtomicReference<>( RpcClientStatus.WAIT_INIT); @@ -115,22 +115,21 @@ public abstract class RpcClient implements Closeable { } public RpcClient(String name) { - this.name = name; + this(name, null); } public RpcClient(ServerListFactory serverListFactory) { - this.serverListFactory = serverListFactory; - rpcClientStatus.compareAndSet(RpcClientStatus.WAIT_INIT, RpcClientStatus.INITIALIZED); - LoggerUtils.printIfInfoEnabled(LOGGER, "RpcClient init in constructor, ServerListFactory = {}", - serverListFactory.getClass().getName()); + this(null, serverListFactory); } public RpcClient(String name, ServerListFactory serverListFactory) { - this(name); - this.serverListFactory = serverListFactory; - rpcClientStatus.compareAndSet(RpcClientStatus.WAIT_INIT, RpcClientStatus.INITIALIZED); - LoggerUtils.printIfInfoEnabled(LOGGER, "RpcClient init in constructor, ServerListFactory = {}", - serverListFactory.getClass().getName()); + this.name = name; + if (serverListFactory != null) { + this.serverListFactory = serverListFactory; + rpcClientStatus.compareAndSet(RpcClientStatus.WAIT_INIT, RpcClientStatus.INITIALIZED); + LoggerUtils.printIfInfoEnabled(LOGGER, "RpcClient init in constructor, ServerListFactory = {}", + serverListFactory.getClass().getName()); + } } /** @@ -913,7 +912,7 @@ public abstract class RpcClient implements Closeable { if (matcher.find()) { serverAddress = matcher.group(1); } - + String[] ipPortTuple = serverAddress.split(Constants.COLON, 2); int defaultPort = Integer.parseInt(System.getProperty("nacos.server.port", "8848")); String serverPort = CollectionUtils.getOrDefault(ipPortTuple, 1, Integer.toString(defaultPort));