<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.6.2</li>
<li>Operating System version: win 10, spring-boot 1.5.9.RELEASE</li>
<li>Java version: 1.8</li>
</ul>
<h3 dir="auto">Steps to reproduce this issue</h3>
<ol dir="auto">
<li>Java config</li>
</ol>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="@Configuration
public class HttpConfig {

    @Bean
    RestTemplate restTemplate(){
        RestTemplate restTemplate = new RestTemplate();
        return  restTemplate;
    }
}"><pre class="notranslate"><span class="pl-c1">@</span><span class="pl-c1">Configuration</span>
<span class="pl-k">public</span> <span class="pl-k">class</span> <span class="pl-smi">HttpConfig</span> {

    <span class="pl-c1">@</span><span class="pl-c1">Bean</span>
    <span class="pl-smi">RestTemplate</span> <span class="pl-en">restTemplate</span>(){
        <span class="pl-smi">RestTemplate</span> <span class="pl-s1">restTemplate</span> = <span class="pl-k">new</span> <span class="pl-smi">RestTemplate</span>();
        <span class="pl-k">return</span>  <span class="pl-s1">restTemplate</span>;
    }
}</pre></div>
<ol start="2" dir="auto">
<li>Dubbo Service config</li>
</ol>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="@Configuration
public class CanaryConfig {

    private Logger logger = LoggerFactory.getLogger(CanaryConfig.class);

    @Autowired
    private ApplicationConfig application;
    @Autowired
    private RegistryConfig registry;
    @Autowired
    private ProtocolConfig protocol;

    @PostConstruct
    public void init() {
        logger.info(&quot;CanaryConfig init ...&quot;);
        // 服务提供者暴露服务配置

        // 此实例很重，封装了与注册中心的连接，请自行缓存，否则可能造成内存和连接泄漏
        ServiceConfig&lt;CanaryService&gt; service = new ServiceConfig&lt;&gt;();
        service.setApplication(application);
        // 多个注册中心可以用setRegistries()
        service.setRegistry(registry);
        // 多个协议可以用setProtocols()
        service.setProtocol(protocol);
        service.setInterface(CanaryService.class);
        service.setRef(new CanaryServiceImpl());
        service.setFilter(&quot;tracing,dubboInterfaceAuthorityFilter,dubboLogFilter&quot;);
        // 如果不延迟暴露, 则filter无法进入setter来获取spring实例
        // service.setDelay(5000);

        // 暴露及注册服务
        service.export();
    }

}"><pre class="notranslate"><span class="pl-c1">@</span><span class="pl-c1">Configuration</span>
<span class="pl-k">public</span> <span class="pl-k">class</span> <span class="pl-smi">CanaryConfig</span> {

    <span class="pl-k">private</span> <span class="pl-smi">Logger</span> <span class="pl-s1">logger</span> = <span class="pl-smi">LoggerFactory</span>.<span class="pl-en">getLogger</span>(<span class="pl-smi">CanaryConfig</span>.<span class="pl-k">class</span>);

    <span class="pl-c1">@</span><span class="pl-c1">Autowired</span>
    <span class="pl-k">private</span> <span class="pl-smi">ApplicationConfig</span> <span class="pl-s1">application</span>;
    <span class="pl-c1">@</span><span class="pl-c1">Autowired</span>
    <span class="pl-k">private</span> <span class="pl-smi">RegistryConfig</span> <span class="pl-s1">registry</span>;
    <span class="pl-c1">@</span><span class="pl-c1">Autowired</span>
    <span class="pl-k">private</span> <span class="pl-smi">ProtocolConfig</span> <span class="pl-s1">protocol</span>;

    <span class="pl-c1">@</span><span class="pl-c1">PostConstruct</span>
    <span class="pl-k">public</span> <span class="pl-smi">void</span> <span class="pl-en">init</span>() {
        <span class="pl-s1">logger</span>.<span class="pl-en">info</span>(<span class="pl-s">"CanaryConfig init ..."</span>);
        <span class="pl-c">// 服务提供者暴露服务配置</span>

        <span class="pl-c">// 此实例很重，封装了与注册中心的连接，请自行缓存，否则可能造成内存和连接泄漏</span>
        <span class="pl-smi">ServiceConfig</span>&lt;<span class="pl-smi">CanaryService</span>&gt; <span class="pl-s1">service</span> = <span class="pl-k">new</span> <span class="pl-smi">ServiceConfig</span>&lt;&gt;();
        <span class="pl-s1">service</span>.<span class="pl-en">setApplication</span>(<span class="pl-s1">application</span>);
        <span class="pl-c">// 多个注册中心可以用setRegistries()</span>
        <span class="pl-s1">service</span>.<span class="pl-en">setRegistry</span>(<span class="pl-s1">registry</span>);
        <span class="pl-c">// 多个协议可以用setProtocols()</span>
        <span class="pl-s1">service</span>.<span class="pl-en">setProtocol</span>(<span class="pl-s1">protocol</span>);
        <span class="pl-s1">service</span>.<span class="pl-en">setInterface</span>(<span class="pl-smi">CanaryService</span>.<span class="pl-k">class</span>);
        <span class="pl-s1">service</span>.<span class="pl-en">setRef</span>(<span class="pl-k">new</span> <span class="pl-smi">CanaryServiceImpl</span>());
        <span class="pl-s1">service</span>.<span class="pl-en">setFilter</span>(<span class="pl-s">"tracing,dubboInterfaceAuthorityFilter,dubboLogFilter"</span>);
        <span class="pl-c">// 如果不延迟暴露, 则filter无法进入setter来获取spring实例</span>
        <span class="pl-c">// service.setDelay(5000);</span>

        <span class="pl-c">// 暴露及注册服务</span>
        <span class="pl-s1">service</span>.<span class="pl-en">export</span>();
    }

}</pre></div>
<ol start="3" dir="auto">
<li>Dubbo filter(in another dependency jar)</li>
</ol>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="@Activate(group = {Constants.PROVIDER, Constants.CONSUMER})
public class DubboInterfaceAuthorityFilter implements Filter {
    private static final Logger logger = LoggerFactory.getLogger(DubboInterfaceAuthorityFilter.class);

    public void setRestTemplate(RestTemplate restTemplate) {
        // get restTemplate instance from spring
        logger.info(&quot; into setter&quot;);
    }

    @Override
    public Result invoke(Invoker&lt;?&gt; invoker, Invocation invocation) throws RpcException {
        if(restTemplate!=null){
             // my code
        }
        // ...
    }
}"><pre class="notranslate"><span class="pl-c1">@</span><span class="pl-c1">Activate</span>(<span class="pl-s1">group</span> = {<span class="pl-smi">Constants</span>.<span class="pl-c1">PROVIDER</span>, <span class="pl-smi">Constants</span>.<span class="pl-c1">CONSUMER</span>})
<span class="pl-k">public</span> <span class="pl-k">class</span> <span class="pl-smi">DubboInterfaceAuthorityFilter</span> <span class="pl-k">implements</span> <span class="pl-smi">Filter</span> {
    <span class="pl-k">private</span> <span class="pl-k">static</span> <span class="pl-k">final</span> <span class="pl-smi">Logger</span> <span class="pl-s1">logger</span> = <span class="pl-smi">LoggerFactory</span>.<span class="pl-en">getLogger</span>(<span class="pl-smi">DubboInterfaceAuthorityFilter</span>.<span class="pl-k">class</span>);

    <span class="pl-k">public</span> <span class="pl-smi">void</span> <span class="pl-en">setRestTemplate</span>(<span class="pl-smi">RestTemplate</span> <span class="pl-s1">restTemplate</span>) {
        <span class="pl-c">// get restTemplate instance from spring</span>
        <span class="pl-s1">logger</span>.<span class="pl-en">info</span>(<span class="pl-s">" into setter"</span>);
    }

    <span class="pl-c1">@</span><span class="pl-c1">Override</span>
    <span class="pl-k">public</span> <span class="pl-smi">Result</span> <span class="pl-en">invoke</span>(<span class="pl-smi">Invoker</span>&lt;?&gt; <span class="pl-s1">invoker</span>, <span class="pl-smi">Invocation</span> <span class="pl-s1">invocation</span>) <span class="pl-k">throws</span> <span class="pl-smi">RpcException</span> {
        <span class="pl-k">if</span>(<span class="pl-s1">restTemplate</span>!=<span class="pl-c1">null</span>){
             <span class="pl-c">// my code</span>
        }
        <span class="pl-c">// ...</span>
    }
}</pre></div>
<p dir="auto">Pls. provide [GitHub address] to reproduce this issue.</p>
<h3 dir="auto">Expected Result</h3>
<p dir="auto">DubboInterfaceAuthorityFilter can invoke its setRestTemplate method, to get restTemplate instance from spring</p>
<h3 dir="auto">Actual Result</h3>
<p dir="auto">DubboInterfaceAuthorityFilter do not invoke setRestTemplate method, so that restTemplate is always null in my filter.</p>
<h3 dir="auto">By the way</h3>
<p dir="auto">If i <code class="notranslate">service.setDelay(5000);</code> or export this service by dubbo xml:</p>
<div class="highlight highlight-text-xml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&lt;dubbo:service interface=&quot;com.canary.service.CanaryService&quot; ref=&quot;canaryServiceImpl&quot; version=&quot;1.0.3&quot;/&gt;
&lt;bean id=&quot;canaryServiceImpl&quot; class=&quot;com.canary.service.CanaryServiceImpl&quot;/&gt;"><pre class="notranslate">&lt;<span class="pl-ent">dubbo</span><span class="pl-ent">:</span><span class="pl-ent">service</span> <span class="pl-e">interface</span>=<span class="pl-s"><span class="pl-pds">"</span>com.canary.service.CanaryService<span class="pl-pds">"</span></span> <span class="pl-e">ref</span>=<span class="pl-s"><span class="pl-pds">"</span>canaryServiceImpl<span class="pl-pds">"</span></span> <span class="pl-e">version</span>=<span class="pl-s"><span class="pl-pds">"</span>1.0.3<span class="pl-pds">"</span></span>/&gt;
&lt;<span class="pl-ent">bean</span> <span class="pl-e">id</span>=<span class="pl-s"><span class="pl-pds">"</span>canaryServiceImpl<span class="pl-pds">"</span></span> <span class="pl-e">class</span>=<span class="pl-s"><span class="pl-pds">"</span>com.canary.service.CanaryServiceImpl<span class="pl-pds">"</span></span>/&gt;</pre></div>
<p dir="auto">DubboInterfaceAuthorityFilter will invoke its setRestTemplate method.</p>
<p dir="auto"><strong>Why ?</strong></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/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.3-SNAPSHOT</li>
<li>Operating System version: macOs</li>
<li>Java version: JDK 1.8</li>
</ul>
<h3 dir="auto">Steps to reproduce this issue</h3>
<ol dir="auto">
<li>We cannot getFuture from alibaba RpcContext after setFuture, the result is null.</li>
</ol>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="CompletableFuture future = new CompletableFuture();
com.alibaba.dubbo.rpc.RpcContext.getContext().setFuture(future);
Future result = com.alibaba.dubbo.rpc.RpcContext.getContext().getFuture();"><pre class="notranslate"><code class="notranslate">CompletableFuture future = new CompletableFuture();
com.alibaba.dubbo.rpc.RpcContext.getContext().setFuture(future);
Future result = com.alibaba.dubbo.rpc.RpcContext.getContext().getFuture();
</code></pre></div>
<p dir="auto">Pls. provide [GitHub address] to reproduce this issue.</p>
<h3 dir="auto">Expected Result</h3>
<p dir="auto">result should be same new FutureAdapter(future);</p>
<h3 dir="auto">Actual Result</h3>
<p dir="auto">result is null.</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>