Skip to content

Commit

Permalink
Merge pull request #5241 from KomachiSion/2.0.0-bugfix
Browse files Browse the repository at this point in the history
Upgrade to 2.0.0 bugfix
  • Loading branch information
KomachiSion authored Mar 30, 2021
2 parents 580f73e + 2c55f4f commit e6de274
Show file tree
Hide file tree
Showing 79 changed files with 2,459 additions and 1,017 deletions.
10 changes: 0 additions & 10 deletions address/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ public class ServerListManager implements ServerListFactory, Closeable {

private final AtomicInteger currentIndex = new AtomicInteger();

private List<String> serversFromEndpoint = new ArrayList<String>();
private final List<String> serverList = new ArrayList<>();

private List<String> serverList = new ArrayList<String>();
private List<String> serversFromEndpoint = new ArrayList<>();

private ScheduledExecutorService refreshServerListExecutor;

Expand All @@ -85,12 +85,9 @@ private void initServerAddr(Properties properties) {
this.serversFromEndpoint = getServerListFromEndpoint();
refreshServerListExecutor = new ScheduledThreadPoolExecutor(1,
new NameThreadFactory("com.alibaba.nacos.client.naming.server.list.refresher"));
refreshServerListExecutor.scheduleWithFixedDelay(new Runnable() {
@Override
public void run() {
refreshServerListIfNeed();
}
}, 0, refreshServerListInternal, TimeUnit.MILLISECONDS);
refreshServerListExecutor
.scheduleWithFixedDelay(this::refreshServerListIfNeed, 0, refreshServerListInternal,
TimeUnit.MILLISECONDS);
} else {
String serverListFromProps = properties.getProperty(PropertyKeyConst.SERVER_ADDR);
if (StringUtils.isNotEmpty(serverListFromProps)) {
Expand Down Expand Up @@ -138,7 +135,7 @@ private void refreshServerListIfNeed() {
if (CollectionUtils.isEmpty(list)) {
throw new Exception("Can not acquire Nacos list");
}
if (!CollectionUtils.isEqualCollection(list, serversFromEndpoint)) {
if (null == serversFromEndpoint || !CollectionUtils.isEqualCollection(list, serversFromEndpoint)) {
NAMING_LOGGER.info("[SERVER-LIST] server list is updated: " + list);
}
serversFromEndpoint = list;
Expand All @@ -156,6 +153,7 @@ public String getNacosDomain() {
return nacosDomain;
}

@Override
public List<String> getServerList() {
return serverList.isEmpty() ? serversFromEndpoint : serverList;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;

/**
* Chooser.
Expand Down

This file was deleted.

Loading

0 comments on commit e6de274

Please sign in to comment.