<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-SNAPSHOT</li>
<li>Operating System version: mac os 10.13.6</li>
<li>Java version: 1.8.0_171</li>
</ul>
<h3 dir="auto">Steps to reproduce this issue</h3>
<ol dir="auto">
<li>run the code in unit test:</li>
</ol>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="   @Test
    public void testRestProtocol() {
        protocol = ExtensionLoader.getExtensionLoader(Protocol.class).getExtension(&quot;rest&quot;);
        URL url = URL.valueOf(&quot;rest://127.0.0.1:5342/rest/say?version=1.0.0&amp;interface=org.apache.dubbo.rpc.protocol.rest.DemoService&quot;);
        while (true) {
            Invoker&lt;DemoService&gt; invoker = protocol.refer(DemoService.class, url);
            invoker.destroy();
        }
    }"><pre class="notranslate">   <span class="pl-c1">@</span><span class="pl-c1">Test</span>
    <span class="pl-k">public</span> <span class="pl-smi">void</span> <span class="pl-s1">testRestProtocol</span>() {
        <span class="pl-s1">protocol</span> = <span class="pl-smi">ExtensionLoader</span>.<span class="pl-en">getExtensionLoader</span>(<span class="pl-smi">Protocol</span>.<span class="pl-k">class</span>).<span class="pl-en">getExtension</span>(<span class="pl-s">"rest"</span>);
        <span class="pl-smi">URL</span> <span class="pl-s1">url</span> = <span class="pl-smi">URL</span>.<span class="pl-en">valueOf</span>(<span class="pl-s">"rest://127.0.0.1:5342/rest/say?version=1.0.0&amp;interface=org.apache.dubbo.rpc.protocol.rest.DemoService"</span>);
        <span class="pl-k">while</span> (<span class="pl-c1">true</span>) {
            <span class="pl-smi">Invoker</span>&lt;<span class="pl-smi">DemoService</span>&gt; <span class="pl-s1">invoker</span> = <span class="pl-s1">protocol</span>.<span class="pl-en">refer</span>(<span class="pl-smi">DemoService</span>.<span class="pl-k">class</span>, <span class="pl-s1">url</span>);
            <span class="pl-s1">invoker</span>.<span class="pl-en">destroy</span>();
        }
    }</pre></div>
<p dir="auto">Pls. provide [GitHub address] to reproduce this issue.</p>
<h3 dir="auto">Actual Result</h3>
<p dir="auto">What actually happens?<br>
the size of LinkedList [clients] will keep growing, the ResteasyClient hold by it will not release, which will cause OOM easily.</p>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content=" ResteasyClient client = new ResteasyClientBuilder().httpEngine(engine).build();
clients.add(client);"><pre class="notranslate"> <span class="pl-smi">ResteasyClient</span> <span class="pl-s1">client</span> = <span class="pl-k">new</span> <span class="pl-smi">ResteasyClientBuilder</span>().<span class="pl-en">httpEngine</span>(<span class="pl-s1">engine</span>).<span class="pl-en">build</span>();
<span class="pl-s1">clients</span>.<span class="pl-en">add</span>(<span class="pl-s1">client</span>);</pre></div>
<p dir="auto">the clients in the linkedList will not release when invoker destroyed, they will only be released when the rest protocol destroyed.<br>
I think the protocol layer should not hold the object's such like client, it should be hold by the invoker and has the same lifecycle with invoker</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</li>
<li>Operating System version: windows10</li>
<li>Java version: JDK1.8</li>
</ul>
<h3 dir="auto">Steps to reproduce this issue</h3>
<ol dir="auto">
<li>set onconnect,ondisconnect parameter on <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></li>
<li>write onconnect,ondisconnect callback on consumer</li>
</ol>
<p dir="auto">code:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="@Reference(onconnect = &quot;onconnect&quot;)
private HelloDubboService helloDubboService;

public void onconnect(){
    System.out.println(&quot;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;onconnect()&quot;);
}"><pre class="notranslate"><code class="notranslate">@Reference(onconnect = "onconnect")
private HelloDubboService helloDubboService;

public void onconnect(){
    System.out.println("&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;onconnect()");
}
</code></pre></div>
<h3 dir="auto">Expected Result</h3>
<p dir="auto">it should invoke onconnect ,ondisconnect callback when the consumer connect the provider</p>
<h3 dir="auto">Actual Result</h3>
<p dir="auto">it does not work</p>
<p dir="auto">is it a bug?or these callback only be used on provider side?</p>