<ul dir="auto">
<li>[x ] 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>[x ] 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.6</li>
<li>Operating System version: Mac OS 10.13.6</li>
<li>Java version: 1.8.0_202-b08 Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)</li>
</ul>
<p dir="auto">We were using Dubbo 2.7.3 before upgrading to Dubbo 2.7.6 (the most recent release).<br>
As Dubbo does not support serialization of several classType (for instance, <strong>InputStream</strong>), we have implement our own serialization by extending the ObjectInput and ObjectOutput classes.<br>
It was working properly with Dubbo 2.7.3.</p>
<p dir="auto">When we upgrade to Dubbo 2.7.6, the AsyncRpcResult.getAppResponse keeps failing at getting the response.</p>
<p dir="auto">Our question is: Does we need to do more than implementing the de/serialization to make Dubbo support extra classtypes in our exporting APIs?</p>
<h3 dir="auto">Stack trace</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Exception in thread &quot;main&quot; org.apache.dubbo.rpc.RpcException: java.util.concurrent.ExecutionException: java.lang.RuntimeException
	at org.apache.dubbo.rpc.AsyncRpcResult.getAppResponse(AsyncRpcResult.java:151)
	at org.apache.dubbo.rpc.AsyncRpcResult.recreate(AsyncRpcResult.java:191)
	at org.apache.dubbo.rpc.proxy.InvokerInvocationHandler.invoke(InvokerInvocationHandler.java:74)
	at org.apache.dubbo.common.bytecode.proxy0.getFile(proxy0.java)
	at org.apache.dubbo.demo.consumer.Application.runWithBootstrap(Application.java:69)
	at org.apache.dubbo.demo.consumer.Application.main(Application.java:39)
Caused by: java.util.concurrent.ExecutionException: java.lang.RuntimeException
	at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)
	at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1895)
	at org.apache.dubbo.rpc.AsyncRpcResult.getAppResponse(AsyncRpcResult.java:146)
	... 5 more
Caused by: java.lang.RuntimeException
	at org.apache.dubbo.common.utils.PojoUtils.newInstance(PojoUtils.java:559)
	at org.apache.dubbo.common.utils.PojoUtils.realize0(PojoUtils.java:452)
	at org.apache.dubbo.common.utils.PojoUtils.realize(PojoUtils.java:209)
	at org.apache.dubbo.rpc.filter.GenericImplFilter.onResponse(GenericImplFilter.java:166)
	at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.lambda$invoke$0(ProtocolFilterWrapper.java:119)
	at org.apache.dubbo.rpc.AsyncRpcResult.lambda$whenCompleteWithContext$0(AsyncRpcResult.java:197)
	at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:760)
	at java.util.concurrent.CompletableFuture.uniWhenCompleteStage(CompletableFuture.java:778)
	at java.util.concurrent.CompletableFuture.whenComplete(CompletableFuture.java:2140)
	at org.apache.dubbo.rpc.AsyncRpcResult.whenCompleteWithContext(AsyncRpcResult.java:195)
	at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:101)
	at org.apache.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:89)
	at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:81)
	at org.apache.dubbo.rpc.protocol.dubbo.filter.FutureFilter.invoke(FutureFilter.java:51)
	at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:81)
	at org.apache.dubbo.rpc.filter.ConsumerContextFilter.invoke(ConsumerContextFilter.java:55)
	at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:81)
	at org.apache.dubbo.rpc.listener.ListenerInvokerWrapper.invoke(ListenerInvokerWrapper.java:78)
	at org.apache.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:56)
	at org.apache.dubbo.rpc.cluster.support.FailoverClusterInvoker.doInvoke(FailoverClusterInvoker.java:82)
	at org.apache.dubbo.rpc.cluster.support.AbstractClusterInvoker.invoke(AbstractClusterInvoker.java:259)
	at org.apache.dubbo.rpc.cluster.interceptor.ClusterInterceptor.intercept(ClusterInterceptor.java:47)
	at org.apache.dubbo.rpc.cluster.support.wrapper.AbstractCluster$InterceptorInvokerNode.invoke(AbstractCluster.java:92)
	at org.apache.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker.invoke(MockClusterInvoker.java:82)
	... 4 more
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at org.apache.dubbo.common.utils.PojoUtils.newInstance(PojoUtils.java:553)
	... 27 more
Caused by: java.lang.NullPointerException
	at java.io.FileInputStream.&lt;init&gt;(FileInputStream.java:168)
	... 32 more"><pre class="notranslate"><code class="notranslate">Exception in thread "main" org.apache.dubbo.rpc.RpcException: java.util.concurrent.ExecutionException: java.lang.RuntimeException
	at org.apache.dubbo.rpc.AsyncRpcResult.getAppResponse(AsyncRpcResult.java:151)
	at org.apache.dubbo.rpc.AsyncRpcResult.recreate(AsyncRpcResult.java:191)
	at org.apache.dubbo.rpc.proxy.InvokerInvocationHandler.invoke(InvokerInvocationHandler.java:74)
	at org.apache.dubbo.common.bytecode.proxy0.getFile(proxy0.java)
	at org.apache.dubbo.demo.consumer.Application.runWithBootstrap(Application.java:69)
	at org.apache.dubbo.demo.consumer.Application.main(Application.java:39)
Caused by: java.util.concurrent.ExecutionException: java.lang.RuntimeException
	at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)
	at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1895)
	at org.apache.dubbo.rpc.AsyncRpcResult.getAppResponse(AsyncRpcResult.java:146)
	... 5 more
Caused by: java.lang.RuntimeException
	at org.apache.dubbo.common.utils.PojoUtils.newInstance(PojoUtils.java:559)
	at org.apache.dubbo.common.utils.PojoUtils.realize0(PojoUtils.java:452)
	at org.apache.dubbo.common.utils.PojoUtils.realize(PojoUtils.java:209)
	at org.apache.dubbo.rpc.filter.GenericImplFilter.onResponse(GenericImplFilter.java:166)
	at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.lambda$invoke$0(ProtocolFilterWrapper.java:119)
	at org.apache.dubbo.rpc.AsyncRpcResult.lambda$whenCompleteWithContext$0(AsyncRpcResult.java:197)
	at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:760)
	at java.util.concurrent.CompletableFuture.uniWhenCompleteStage(CompletableFuture.java:778)
	at java.util.concurrent.CompletableFuture.whenComplete(CompletableFuture.java:2140)
	at org.apache.dubbo.rpc.AsyncRpcResult.whenCompleteWithContext(AsyncRpcResult.java:195)
	at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:101)
	at org.apache.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:89)
	at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:81)
	at org.apache.dubbo.rpc.protocol.dubbo.filter.FutureFilter.invoke(FutureFilter.java:51)
	at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:81)
	at org.apache.dubbo.rpc.filter.ConsumerContextFilter.invoke(ConsumerContextFilter.java:55)
	at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:81)
	at org.apache.dubbo.rpc.listener.ListenerInvokerWrapper.invoke(ListenerInvokerWrapper.java:78)
	at org.apache.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:56)
	at org.apache.dubbo.rpc.cluster.support.FailoverClusterInvoker.doInvoke(FailoverClusterInvoker.java:82)
	at org.apache.dubbo.rpc.cluster.support.AbstractClusterInvoker.invoke(AbstractClusterInvoker.java:259)
	at org.apache.dubbo.rpc.cluster.interceptor.ClusterInterceptor.intercept(ClusterInterceptor.java:47)
	at org.apache.dubbo.rpc.cluster.support.wrapper.AbstractCluster$InterceptorInvokerNode.invoke(AbstractCluster.java:92)
	at org.apache.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker.invoke(MockClusterInvoker.java:82)
	... 4 more
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at org.apache.dubbo.common.utils.PojoUtils.newInstance(PojoUtils.java:553)
	... 27 more
Caused by: java.lang.NullPointerException
	at java.io.FileInputStream.&lt;init&gt;(FileInputStream.java:168)
	... 32 more
</code></pre></div>
<p dir="auto">We will try to create a quick github project so that you can reproduce the exception easily if you need to.</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.1</li>
<li>Operating System version: Fedora 29</li>
<li>Java version: SE 11 (18.9)</li>
</ul>
<h3 dir="auto">Steps to reproduce this issue</h3>
<ol dir="auto">
<li>Make service like this</li>
</ol>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="@Service(interfaceClass = MessagingService.class, methods = {
        @Method(name = &quot;addMessageListener&quot;, arguments = {
                @Argument(index = 0, callback = true)
        })
})
public class MessagingServiceImpl implements MessagingService {

    @Override
    public void addMessageListener(MessageListener listener) {
        //...
    }
}"><pre class="notranslate"><span class="pl-c1">@</span><span class="pl-c1">Service</span>(<span class="pl-s1">interfaceClass</span> = <span class="pl-smi">MessagingService</span>.<span class="pl-k">class</span>, <span class="pl-s1">methods</span> = {
        <span class="pl-c1">@</span><span class="pl-c1">Method</span>(<span class="pl-s1">name</span> = <span class="pl-s">"addMessageListener"</span>, <span class="pl-s1">arguments</span> = {
                <span class="pl-c1">@</span><span class="pl-c1">Argument</span>(<span class="pl-s1">index</span> = <span class="pl-c1">0</span>, <span class="pl-s1">callback</span> = <span class="pl-c1">true</span>)
        })
})
<span class="pl-k">public</span> <span class="pl-k">class</span> <span class="pl-smi">MessagingServiceImpl</span> <span class="pl-k">implements</span> <span class="pl-smi">MessagingService</span> {

    <span class="pl-c1">@</span><span class="pl-c1">Override</span>
    <span class="pl-k">public</span> <span class="pl-smi">void</span> <span class="pl-en">addMessageListener</span>(<span class="pl-smi">MessageListener</span> <span class="pl-s1">listener</span>) {
        <span class="pl-c">//...</span>
    }
}</pre></div>
<ol start="2" dir="auto">
<li>Call method <strong>addMessageListener</strong> on consumer side</li>
</ol>
<h3 dir="auto">Expected Result</h3>
<p dir="auto">No exceptions thrown</p>
<h3 dir="auto">Actual Result</h3>
<p dir="auto">Throws <strong>IllegalStateException</strong></p>
<p dir="auto"><em>Caused by: org.apache.dubbo.rpc.RpcException: Failed to invoke remote method: addMessageListener, provider: dubbo://127.0.0.1:20880/com.example.api.service.MessagingService?application=dubbo-spring-boot-starter&amp;default.generic=false&amp;default.lazy=false&amp;default.sticky=false&amp;dubbo=2.0.2&amp;generic=false&amp;interface=com.example.api.service.MessagingService&amp;lazy=false&amp;methods=addMessageListener&amp;pid=5389&amp;register.ip=192.168.1.103&amp;revision=0.0.1-SNAPSHOT&amp;side=consumer&amp;sticky=false&amp;timestamp=1563276164135, cause: io.netty.handler.codec.EncoderException: java.lang.IllegalStateException: Serialized class com.example.client.controller.MainController$1 must implement java.io.Serializable<br>
io.netty.handler.codec.EncoderException: java.lang.IllegalStateException: Serialized class com.example.client.controller.MainController$1 must implement java.io.Serializable</em></p>