<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have searched the <a href="https://github.com/apache/dubbo/issues">issues</a> of this repository and believe that this is not a duplicate.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have checked the <a href="https://github.com/apache/dubbo/blob/master/FAQ.md">FAQ</a> of this repository and believe that this is not a duplicate.</li>
</ul>
<h3 dir="auto">Environment</h3>
<ul dir="auto">
<li>Dubbo version: 2.7.3</li>
<li>Operating System version: macOS 10.14.6</li>
<li>Java version: 1.8</li>
</ul>
<h3 dir="auto">Steps to reproduce this issue</h3>
<p dir="auto">在我项目中，<strong>配置中心</strong>和<strong>注册中心</strong>都是使用zookeeper，而且是在一个集群上，只是 <strong>path</strong> 和对应的 <strong>username</strong> 和 <strong>password</strong> 不同，但是并未正常初始化两个不同的zk client。</p>
<p dir="auto">项目启动时：<br>
1、连接配置中心的地址，获取<strong>配置中心</strong>的配置信息<br>
2、在初始化ReferenceBean和ServiceBean，会校验<strong>注册中心</strong>是否初始化</p>
<p dir="auto">两者都通过 AbstractZookeeperTransporter#connect(URL url) 方法去连接zk</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="public abstract class AbstractZookeeperTransporter implements ZookeeperTransporter {
    //缓存 zk client，key为zk地址
    private final Map&lt;String, ZookeeperClient&gt; zookeeperClientMap = new ConcurrentHashMap&lt;&gt;();

    
    @Override
    public ZookeeperClient connect(URL url) {
        ZookeeperClient zookeeperClient;
        List&lt;String&gt; addressList = getURLBackupAddress(url);
        // 这个地方会走缓存
        if ((zookeeperClient = fetchAndUpdateZookeeperClientCache(addressList)) != null &amp;&amp; zookeeperClient.isConnected()) {
            logger.info(&quot;find valid zookeeper client from the cache for address: &quot; + url);
            return zookeeperClient;
        }
        。。。
    }

    ZookeeperClient fetchAndUpdateZookeeperClientCache(List&lt;String&gt; addressList) {

        ZookeeperClient zookeeperClient = null;
        for (String address : addressList) {
            if ((zookeeperClient = zookeeperClientMap.get(address)) != null &amp;&amp; zookeeperClient.isConnected()) {
                break;
            }
        }
        if (zookeeperClient != null &amp;&amp; zookeeperClient.isConnected()) {
            //将 zookeeperClient 放入 zookeeperClientMap 缓存中
            writeToClientMap(addressList, zookeeperClient);
        }
        return zookeeperClient;
    }
    void writeToClientMap(List&lt;String&gt; addressList, ZookeeperClient zookeeperClient) {
        for (String address : addressList) {
            // 使用 address 作为key
            zookeeperClientMap.put(address, zookeeperClient);
        }
    }
}"><pre class="notranslate"><code class="notranslate">public abstract class AbstractZookeeperTransporter implements ZookeeperTransporter {
    //缓存 zk client，key为zk地址
    private final Map&lt;String, ZookeeperClient&gt; zookeeperClientMap = new ConcurrentHashMap&lt;&gt;();

    
    @Override
    public ZookeeperClient connect(URL url) {
        ZookeeperClient zookeeperClient;
        List&lt;String&gt; addressList = getURLBackupAddress(url);
        // 这个地方会走缓存
        if ((zookeeperClient = fetchAndUpdateZookeeperClientCache(addressList)) != null &amp;&amp; zookeeperClient.isConnected()) {
            logger.info("find valid zookeeper client from the cache for address: " + url);
            return zookeeperClient;
        }
        。。。
    }

    ZookeeperClient fetchAndUpdateZookeeperClientCache(List&lt;String&gt; addressList) {

        ZookeeperClient zookeeperClient = null;
        for (String address : addressList) {
            if ((zookeeperClient = zookeeperClientMap.get(address)) != null &amp;&amp; zookeeperClient.isConnected()) {
                break;
            }
        }
        if (zookeeperClient != null &amp;&amp; zookeeperClient.isConnected()) {
            //将 zookeeperClient 放入 zookeeperClientMap 缓存中
            writeToClientMap(addressList, zookeeperClient);
        }
        return zookeeperClient;
    }
    void writeToClientMap(List&lt;String&gt; addressList, ZookeeperClient zookeeperClient) {
        for (String address : addressList) {
            // 使用 address 作为key
            zookeeperClientMap.put(address, zookeeperClient);
        }
    }
}
</code></pre></div>
<p dir="auto">从上边可以看出，在初始化 <strong>配置中心</strong>的 zk client 后，就缓存到了 zookeeperClientMap 中。<br>
当<strong>注册中心</strong>去初始化zk client 时，由于跟<strong>配置中心</strong>在一个集群上，所以 address相同，就会走缓存，返回 <strong>配置中心</strong>的 zk cliient。</p>
<p dir="auto"><strong>总结</strong>：<br>
如果<strong>配置中心</strong>和<strong>注册中心</strong>在一个集群上，zookeeperClientMap就不能使用address作为key。</p>
<p dir="auto"><strong>解决方案</strong>：<br>
URL信息（配置中心）<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/13186839/64221021-f42abc80-cefd-11e9-8920-d283ae27e864.png"><img src="https://user-images.githubusercontent.com/13186839/64221021-f42abc80-cefd-11e9-8920-d283ae27e864.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">URL信息（注册中心）<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/13186839/64220937-aada6d00-cefd-11e9-8446-69a8f2f95d4a.png"><img src="https://user-images.githubusercontent.com/13186839/64220937-aada6d00-cefd-11e9-8446-69a8f2f95d4a.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">通过上边两个图可以看出，<strong>配置中心</strong> 和  <strong>注册中心</strong> 传入的 URL信息里边的 <strong>path</strong> 是不相同的，将 zookeeperClientMap 的 key 使用 <strong>address + url.path</strong> 的方式生成，就可以解决这个问题</p>
<h1 dir="auto">Weekly Report of Dubbo</h1>
<p dir="auto">This is a weekly report of Dubbo. It summarizes what have changed in the project during the passed week, including pr merged, new contributors, and more things in the future.<br>
It is all done by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/dubbo-bot/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/dubbo-bot">@dubbo-bot</a> which is a collaborate robot.</p>
<h2 dir="auto">Repo Overview</h2>
<h3 dir="auto">Basic data</h3>
<p dir="auto">Baisc data shows how the watch, star, fork and contributors count changed in the passed week.</p>
<table role="table">
<thead>
<tr>
<th align="center">Watch</th>
<th align="center">Star</th>
<th align="center">Fork</th>
<th align="center">Contributors</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">3245</td>
<td align="center">27807 (↑228)</td>
<td align="center">15626 (↑121)</td>
<td align="center">211 (↑3)</td>
</tr>
</tbody>
</table>
<h3 dir="auto">Issues &amp; PRs</h3>
<p dir="auto">Issues &amp; PRs show the new/closed issues/pull requests count in the passed week.</p>
<table role="table">
<thead>
<tr>
<th align="center">New Issues</th>
<th align="center">Closed Issues</th>
<th align="center">New PR</th>
<th align="center">Merged PR</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">35</td>
<td align="center">25</td>
<td align="center">39</td>
<td align="center">19</td>
</tr>
</tbody>
</table>
<h2 dir="auto">PR Overview</h2>
<p dir="auto">Thanks to contributions from community, Dubbo team merged <strong>19</strong> pull requests in the repository last week. They are:</p>
<ul dir="auto">
<li>fix compile issue and refactor metadata structure (<a href="https://github.com/apache/dubbo/pull/4538" data-hovercard-type="pull_request" data-hovercard-url="/apache/dubbo/pull/4538/hovercard">#4538</a>)</li>
<li>Polish /<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="466629009" data-permission-text="Title is private" data-url="https://github.com/apache/dubbo/issues/4535" data-hovercard-type="issue" data-hovercard-url="/apache/dubbo/issues/4535/hovercard" href="https://github.com/apache/dubbo/issues/4535">#4535</a> : [Infrastructure] Update the nacos client … (<a href="https://github.com/apache/dubbo/pull/4537" data-hovercard-type="pull_request" data-hovercard-url="/apache/dubbo/pull/4537/hovercard">#4537</a>)</li>
<li>Upgrade nacos-client dependency version to 1.1.1 (<a href="https://github.com/apache/dubbo/pull/4534" data-hovercard-type="pull_request" data-hovercard-url="/apache/dubbo/pull/4534/hovercard">#4534</a>)</li>
<li>Dubbo throws exception when use java serializer (<a href="https://github.com/apache/dubbo/pull/4530" data-hovercard-type="pull_request" data-hovercard-url="/apache/dubbo/pull/4530/hovercard">#4530</a>)</li>
<li>Use special Configuration for Configs (<a href="https://github.com/apache/dubbo/pull/4522" data-hovercard-type="pull_request" data-hovercard-url="/apache/dubbo/pull/4522/hovercard">#4522</a>)</li>
<li>add -jar for java command (<a href="https://github.com/apache/dubbo/pull/4517" data-hovercard-type="pull_request" data-hovercard-url="/apache/dubbo/pull/4517/hovercard">#4517</a>)</li>
<li>fix length of array is never negative (<a href="https://github.com/apache/dubbo/pull/4510" data-hovercard-type="pull_request" data-hovercard-url="/apache/dubbo/pull/4510/hovercard">#4510</a>)</li>
<li>Polish <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="465698214" data-permission-text="Title is private" data-url="https://github.com/apache/dubbo/issues/4508" data-hovercard-type="issue" data-hovercard-url="/apache/dubbo/issues/4508/hovercard" href="https://github.com/apache/dubbo/issues/4508">#4508</a> : [Version] Update the version of cloud nati… (<a href="https://github.com/apache/dubbo/pull/4509" data-hovercard-type="pull_request" data-hovercard-url="/apache/dubbo/pull/4509/hovercard">#4509</a>)</li>
<li>[Dubbo-4499] org.apache.dubbo.rpc.RpcContext.getFuture() cannot work in Filter. (<a href="https://github.com/apache/dubbo/pull/4504" data-hovercard-type="pull_request" data-hovercard-url="/apache/dubbo/pull/4504/hovercard">#4504</a>)</li>
<li>Polish <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="465592107" data-permission-text="Title is private" data-url="https://github.com/apache/dubbo/issues/4498" data-hovercard-type="issue" data-hovercard-url="/apache/dubbo/issues/4498/hovercard" href="https://github.com/apache/dubbo/issues/4498">#4498</a> : <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/reference/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/reference">@reference</a> can't inject the Dubb… (<a href="https://github.com/apache/dubbo/pull/4503" data-hovercard-type="pull_request" data-hovercard-url="/apache/dubbo/pull/4503/hovercard">#4503</a>)</li>
<li>RpcContext cannot getFuture after setFuture (<a href="https://github.com/apache/dubbo/pull/4502" data-hovercard-type="pull_request" data-hovercard-url="/apache/dubbo/pull/4502/hovercard">#4502</a>)</li>
<li>2.6.x (<a href="https://github.com/apache/dubbo/pull/4495" data-hovercard-type="pull_request" data-hovercard-url="/apache/dubbo/pull/4495/hovercard">#4495</a>)</li>
<li>[dubbo-4491]remove duplicate code in AbstractConfig.java (<a href="https://github.com/apache/dubbo/pull/4492" data-hovercard-type="pull_request" data-hovercard-url="/apache/dubbo/pull/4492/hovercard">#4492</a>)</li>
<li>Make code strong, version check compatibility. (<a href="https://github.com/apache/dubbo/pull/4488" data-hovercard-type="pull_request" data-hovercard-url="/apache/dubbo/pull/4488/hovercard">#4488</a>)</li>
<li>2.6.x to release (<a href="https://github.com/apache/dubbo/pull/4485" data-hovercard-type="pull_request" data-hovercard-url="/apache/dubbo/pull/4485/hovercard">#4485</a>)</li>
<li>[Dubbo-4479]Delete unused code. defaultPort can not be null. <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="464552272" data-permission-text="Title is private" data-url="https://github.com/apache/dubbo/issues/4479" data-hovercard-type="issue" data-hovercard-url="/apache/dubbo/issues/4479/hovercard" href="https://github.com/apache/dubbo/issues/4479">#4479</a> (<a href="https://github.com/apache/dubbo/pull/4480" data-hovercard-type="pull_request" data-hovercard-url="/apache/dubbo/pull/4480/hovercard">#4480</a>)</li>
<li>Redis metadata report support database properties. (<a href="https://github.com/apache/dubbo/pull/4476" data-hovercard-type="pull_request" data-hovercard-url="/apache/dubbo/pull/4476/hovercard">#4476</a>)</li>
<li>FutureAdapter depends on AsyncRpcResult (<a href="https://github.com/apache/dubbo/pull/4471" data-hovercard-type="pull_request" data-hovercard-url="/apache/dubbo/pull/4471/hovercard">#4471</a>)</li>
<li>add 2.7.3 change list (<a href="https://github.com/apache/dubbo/pull/4453" data-hovercard-type="pull_request" data-hovercard-url="/apache/dubbo/pull/4453/hovercard">#4453</a>)</li>
</ul>
<h2 dir="auto">Code Review Statistics</h2>
<p dir="auto">Dubbo encourages everyone to participant in code review, in order to improve software quality. Every week <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/dubbo-bot/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/dubbo-bot">@dubbo-bot</a> would automatically help to count pull request reviews of single github user as the following. So, try to help review code in this project.</p>
<table role="table">
<thead>
<tr>
<th align="center">Contributor ID</th>
<th align="center">Pull Request Reviews</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center"><a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/cvictory/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/cvictory">@cvictory</a></td>
<td align="center">6</td>
</tr>
<tr>
<td align="center"><a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/htynkn/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/htynkn">@htynkn</a></td>
<td align="center">3</td>
</tr>
<tr>
<td align="center"><a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/ralf0131/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/ralf0131">@ralf0131</a></td>
<td align="center">2</td>
</tr>
<tr>
<td align="center"><a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/danielamorais/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/danielamorais">@danielamorais</a></td>
<td align="center">2</td>
</tr>
<tr>
<td align="center"><a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/beiwei30/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/beiwei30">@beiwei30</a></td>
<td align="center">1</td>
</tr>
<tr>
<td align="center"><a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/tswstarplanet/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/tswstarplanet">@tswstarplanet</a></td>
<td align="center">1</td>
</tr>
<tr>
<td align="center"><a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/chickenlj/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/chickenlj">@chickenlj</a></td>
<td align="center">1</td>
</tr>
<tr>
<td align="center"><a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/CrazyHZM/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/CrazyHZM">@CrazyHZM</a></td>
<td align="center">1</td>
</tr>
<tr>
<td align="center"><a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/guohao/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/guohao">@guohao</a></td>
<td align="center">1</td>
</tr>
<tr>
<td align="center">@dntbeSris</td>
<td align="center">1</td>
</tr>
</tbody>
</table>
<h2 dir="auto">Contributors Overview</h2>
<p dir="auto">It is Dubbo team's great honor to have new contributors from community. We really appreciate your contributions. Feel free to tell us if you have any opinion and please share this open source project with more people if you could. If you hope to be a contributor as well, please start from <a href="https://github.com/apache/incubator-dubbo/blob/master/CONTRIBUTING.md">https://github.com/apache/incubator-dubbo/blob/master/CONTRIBUTING.md</a> .<br>
Here is the list of new contributors:</p>
<p dir="auto"><a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/shouhong/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/shouhong">@shouhong</a></p>
<p dir="auto">@liuxx001</p>
<p dir="auto"><a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/TingSky/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/TingSky">@TingSky</a></p>
<p dir="auto">Thanks to you all.</p>
<p dir="auto"><em>Note: This robot is supported by <a href="https://github.com/AlibabaDR/Collabobot">Collabobot</a>.</em></p>