Skip to content

Commit

Permalink
Fix the bug that restarting server leads to the client unavailable. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
QilongZhang authored and leizhiyuan committed Jun 13, 2019
1 parent 3e5381a commit 097a9e4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,7 @@ protected Map<ProviderInfo, ClientTransport> clearProviders() {
aliveConnections.clear();
retryConnections.clear();
uninitializedConnections.clear();
lastAddresses.clear();
return all;
} finally {
providerLock.unlock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,36 @@ public void getAvailableClientTransport3() throws Exception {

consumerConfig.unRefer();
}

@Test
public void getAvailableClientTransport4() throws Exception {
ConsumerConfig<HelloService> consumerConfig = new ConsumerConfig<HelloService>()
.setInterfaceId(HelloService.class.getName())
.setDirectUrl("bolt://127.0.0.1:22223,bolt://127.0.0.1:22224")
.setConnectionHolder("all")
.setRegister(false)
.setLazy(true)
.setTimeout(3000);
HelloService helloService = consumerConfig.refer();
ClientProxyInvoker invoker = (ClientProxyInvoker) ProxyFactory.getInvoker(helloService,
consumerConfig.getProxy());
Cluster cluster = invoker.getCluster();
Assert.assertTrue(cluster.getConnectionHolder() instanceof AllConnectConnectionHolder);
AllConnectConnectionHolder holder = (AllConnectConnectionHolder) cluster.getConnectionHolder();

ProviderGroup providerGroups = new ProviderGroup();
providerGroups.add(ProviderHelper.toProviderInfo("bolt://127.0.0.1:22223"));
providerGroups.add(ProviderHelper.toProviderInfo("bolt://127.0.0.1:22224"));
holder.updateProviders(providerGroups);
Set<ProviderInfo> last = holder.currentProviderList();
Assert.assertEquals(2, last.size());

ProviderGroup providerGroups2 = new ProviderGroup();
holder.updateProviders(providerGroups2);
Set<ProviderInfo> current = holder.currentProviderList();

Assert.assertEquals(0, current.size());

consumerConfig.unRefer();
}
}

0 comments on commit 097a9e4

Please sign in to comment.