<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> 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" checked=""> 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.5-SNAPSHOT</li>
<li>Operating System version: macos</li>
<li>Java version: 1.8.0_131</li>
</ul>
<h3 dir="auto">Steps to reproduce this issue</h3>
<p dir="auto">We could run the following UT, then we could find the issue:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="        ApplicationConfig application = new ApplicationConfig(&quot;provider&quot;);

        ServiceConfig&lt;DemoService&gt; service = new ServiceConfig&lt;DemoService&gt;();
        service.setProtocol(new ProtocolConfig(&quot;dubbo&quot;, 20880));
        service.setRegistry(new RegistryConfig(RegistryConfig.NO_AVAILABLE));
        service.setInterface(DemoService.class);
        service.setRef(new DemoServiceImpl());

        ConsumerConfig consumer = new ConsumerConfig();
        consumer.setLazy(true);

        ReferenceConfig&lt;DemoService&gt; reference = new ReferenceConfig&lt;DemoService&gt;();
        reference.setConsumer(consumer);
        reference.setRegistry(new RegistryConfig(RegistryConfig.NO_AVAILABLE));
        reference.setInterface(DemoService.class);
        reference.setUrl(&quot;dubbo://&quot; + NetUtils.getLocalHost() + &quot;:20880?&quot; + DemoService.class.getName());

        DubboBootstrap bootstrap = DubboBootstrap.getInstance()
            .application(application)
            .service(service)
            .reference(reference)
            .start();

        Assert.assertEquals(&quot;true&quot;, reference.toUrls().get(0).getParameter(&quot;lazy&quot;));"><pre class="notranslate"><code class="notranslate">        ApplicationConfig application = new ApplicationConfig("provider");

        ServiceConfig&lt;DemoService&gt; service = new ServiceConfig&lt;DemoService&gt;();
        service.setProtocol(new ProtocolConfig("dubbo", 20880));
        service.setRegistry(new RegistryConfig(RegistryConfig.NO_AVAILABLE));
        service.setInterface(DemoService.class);
        service.setRef(new DemoServiceImpl());

        ConsumerConfig consumer = new ConsumerConfig();
        consumer.setLazy(true);

        ReferenceConfig&lt;DemoService&gt; reference = new ReferenceConfig&lt;DemoService&gt;();
        reference.setConsumer(consumer);
        reference.setRegistry(new RegistryConfig(RegistryConfig.NO_AVAILABLE));
        reference.setInterface(DemoService.class);
        reference.setUrl("dubbo://" + NetUtils.getLocalHost() + ":20880?" + DemoService.class.getName());

        DubboBootstrap bootstrap = DubboBootstrap.getInstance()
            .application(application)
            .service(service)
            .reference(reference)
            .start();

        Assert.assertEquals("true", reference.toUrls().get(0).getParameter("lazy"));
</code></pre></div>
<h3 dir="auto">Expected Result</h3>
<p dir="auto">Expected "lazy" : true</p>
<h3 dir="auto">Actual Result</h3>
<p dir="auto">Actual "lazy": false</p>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have searched the <a href="https://github.com/apache/incubator-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" checked=""> I have checked the <a href="https://github.com/apache/incubator-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.0</li>
<li>Operating System version: macOS Sierra 10.12</li>
<li>Java version: 1.8.0_111</li>
</ul>
<h3 dir="auto">Steps to reproduce this issue</h3>
<ol dir="auto">
<li>start provider and specific async as true, &lt;dubbo:service interface="" async="true"&gt;</li>
<li>start consumer without async specific.</li>
<li>send a request</li>
</ol>
<p dir="auto">Pls. provide [GitHub address] to reproduce this issue.</p>
<h3 dir="auto">Expected Result</h3>
<p dir="auto">What do you expected from the above steps？<br>
We are able to get the value from the CompletableFuture.<br>
service.sayHello(input);<br>
CompletableFuture future = RpcContext.getContext().getCompletableFuture();<br>
future.whenComplete((retValue, error) -&gt; {<br>
System.out.println(retValue);<br>
});</p>
<h3 dir="auto">Actual Result</h3>
<p dir="auto">What actually happens?<br>
It throws NPE exception as following, as we are not able to get the future.<br>
Exception in thread "main" java.lang.NullPointerException</p>
<p dir="auto">With investigation, it's an issue in RegistryDirectory.<br>
Also, we are able to get async=true from providerUrl, but the querymap's async is false from consumer side. It changed the async from true to false, and caused the issue.</p>
<p dir="auto">private URL mergeUrl(URL providerUrl) {<br>
providerUrl = ClusterUtils.mergeUrl(providerUrl, queryMap);<br>
}</p>
<p dir="auto">If there is an exception, please attach the exception trace:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Just put your stack trace here!"><pre class="notranslate"><code class="notranslate">Just put your stack trace here!
</code></pre></div>