<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.7</li>
<li>Operating System version: centos7</li>
<li>Java version: 1.8</li>
</ul>
<p dir="auto">漏洞链接：<a href="http://www.cnnvd.org.cn/web/xxk/ldxqById.tag?CNNVD=CNNVD-202004-377" rel="nofollow">http://www.cnnvd.org.cn/web/xxk/ldxqById.tag?CNNVD=CNNVD-202004-377</a></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: MacOs</li>
<li>Java version: 1.8</li>
</ul>
<h3 dir="auto">Steps to reproduce this issue</h3>
<p dir="auto">1.start DemoService provider</p>
<p dir="auto">2.Set onreturn and onthrow for sayHello method in async mode, and then start consumer.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;bean id=&quot;demoCallback&quot; class=&quot;com.alibaba.dubbo.samples.notify.impl.NotifyImpl&quot; /&gt;
&lt;dubbo:reference id=&quot;demoService&quot; interface=&quot;com.alibaba.dubbo.DemoService&quot;&gt;
    &lt;dubbo:method name=&quot;sayHello&quot; onreturn=&quot;demoCallback.onreturn&quot; onthrow=&quot;demoCallback.onthrow&quot;/&gt;
&lt;/dubbo:reference&gt;"><pre class="notranslate"><code class="notranslate">&lt;bean id="demoCallback" class="com.alibaba.dubbo.samples.notify.impl.NotifyImpl" /&gt;
&lt;dubbo:reference id="demoService" interface="com.alibaba.dubbo.DemoService"&gt;
    &lt;dubbo:method name="sayHello" onreturn="demoCallback.onreturn" onthrow="demoCallback.onthrow"/&gt;
&lt;/dubbo:reference&gt;
</code></pre></div>
<ol start="2" dir="auto">
<li>send a request in async mode.<br>
When timeout occurred, demoCallback.onthrow callback have not been invoked.</li>
</ol>
<p dir="auto">Pls. provide [GitHub address] to reproduce this issue.</p>
<h3 dir="auto">Expected Result</h3>
<p dir="auto">onthrow callback should be invoked.</p>
<h3 dir="auto">Actual Result</h3>
<p dir="auto">onthrow have not be invoked.</p>
<p dir="auto">If there is an exception, please attach the exception trace:</p>
<p dir="auto">Once exception occurs, CallbackRegistrationInvoker onError will be invoked</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="@Override
public Result invoke(Invocation invocation) throws RpcException {
    Result asyncResult = filterInvoker.invoke(invocation);

    asyncResult = asyncResult.whenCompleteWithContext((r, t) -&gt; {
        for (int i = filters.size() - 1; i &gt;= 0; i--) {
            Filter filter = filters.get(i);
            // onResponse callback
            if (filter instanceof ListenableFilter) {
                Filter.Listener listener = ((ListenableFilter) filter).listener();
                if (listener != null) {
                    if (t == null) {
                        listener.onResponse(r, filterInvoker, invocation);
                    } else {
                        listener.onError(t, filterInvoker, invocation);
                    }
                }
            } else {
                filter.onResponse(r, filterInvoker, invocation);
            }
        }
    });
    return asyncResult;
}"><pre lang="." class="notranslate"><code class="notranslate">@Override
public Result invoke(Invocation invocation) throws RpcException {
    Result asyncResult = filterInvoker.invoke(invocation);

    asyncResult = asyncResult.whenCompleteWithContext((r, t) -&gt; {
        for (int i = filters.size() - 1; i &gt;= 0; i--) {
            Filter filter = filters.get(i);
            // onResponse callback
            if (filter instanceof ListenableFilter) {
                Filter.Listener listener = ((ListenableFilter) filter).listener();
                if (listener != null) {
                    if (t == null) {
                        listener.onResponse(r, filterInvoker, invocation);
                    } else {
                        listener.onError(t, filterInvoker, invocation);
                    }
                }
            } else {
                filter.onResponse(r, filterInvoker, invocation);
            }
        }
    });
    return asyncResult;
}
</code></pre></div>
<p dir="auto">But, the FutureListener's onError is not implemented, cannot invoke the onreturn/onerror callback.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="class FutureListener implements Listener {
    @Override
    public void onResponse(Result result, Invoker&lt;?&gt; invoker, Invocation invocation) {
        if (result.hasException()) {
            fireThrowCallback(invoker, invocation, result.getException());
        } else {
            fireReturnCallback(invoker, invocation, result.getValue());
        }
    }

    @Override
    public void onError(Throwable t, Invoker&lt;?&gt; invoker, Invocation invocation) {

    }
}"><pre class="notranslate"><code class="notranslate">class FutureListener implements Listener {
    @Override
    public void onResponse(Result result, Invoker&lt;?&gt; invoker, Invocation invocation) {
        if (result.hasException()) {
            fireThrowCallback(invoker, invocation, result.getException());
        } else {
            fireReturnCallback(invoker, invocation, result.getValue());
        }
    }

    @Override
    public void onError(Throwable t, Invoker&lt;?&gt; invoker, Invocation invocation) {

    }
}
</code></pre></div>