Skip to content

Commit

Permalink
[ISSUE #10598] Fix nacos-client get the wrong index of the nacos serv…
Browse files Browse the repository at this point in the history
…er list when use nacos-address endpoint (#10599)

* fix nacos clent get the random index of nacos server list bug

* Update ServerListManager.java
  • Loading branch information
1em0n9527 authored Jun 14, 2023
1 parent 780e2f5 commit 4de440d
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,10 @@ public ServerListManager(Properties properties) {
public ServerListManager(NacosClientProperties properties, String namespace) {
this.namespace = namespace;
initServerAddr(properties);
if (!serverList.isEmpty()) {
currentIndex.set(new Random().nextInt(serverList.size()));
}
if (serverList.isEmpty() && StringUtils.isEmpty(endpoint)) {
if (getServerList().isEmpty() && StringUtils.isEmpty(endpoint)) {
throw new NacosLoadException("serverList is empty,please check configuration");
} else {
currentIndex.set(new Random().nextInt(getServerList().size()));
}
}

Expand Down

0 comments on commit 4de440d

Please sign in to comment.