[ISSUE #8709] check serverList size before reconnect to server (#8710)

* [ISSUE #8709] check serverList size before reconnect to server

* use CollectionUtils.isEmpty to judge whether server list  is empty

Co-authored-by: Oliver <wqdyxnbd@163.com>

Co-authored-by: Oliver <wqdyxnbd@163.com>
This commit is contained in:
MajorHe1 2022-07-08 11:52:11 +08:00 committed by GitHub
parent 7bb1e90549
commit 68b521679c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 2 deletions

View File

@ -91,7 +91,7 @@ public class HttpLoginProcessor implements LoginProcessor {
}
return loginIdentityContext;
} catch (Exception e) {
SECURITY_LOGGER.error("[ NacosClientAuthServiceImpl] login http request failed"
SECURITY_LOGGER.error("[NacosClientAuthServiceImpl] login http request failed"
+ " url: {}, params: {}, bodyMap: {}, errorMsg: {}", url, params, bodyMap, e.getMessage());
return null;
}

View File

@ -665,7 +665,7 @@ public class ClientWorker implements Closeable {
@Override
public List<String> getServerList() {
return ConfigRpcTransportClient.super.serverListManager.serverUrls;
return ConfigRpcTransportClient.super.serverListManager.getServerUrls();
}
});

View File

@ -551,6 +551,10 @@ public abstract class RpcClient implements Closeable {
recommendServer.set(null);
}
if (CollectionUtils.isEmpty(RpcClient.this.serverListFactory.getServerList())) {
throw new Exception("server list is empty");
}
if (reConnectTimes > 0
&& reConnectTimes % RpcClient.this.serverListFactory.getServerList().size() == 0) {
LoggerUtils.printIfInfoEnabled(LOGGER,