You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "kexianjun (GitHub)" <gi...@apache.org> on 2019/04/01 05:27:33 UTC
[GitHub] [incubator-dubbo] kexianjun opened issue #3779: problem with
generic parameter when using fastjson serialization
- [ ] I have searched the [issues](https://github.com/apache/incubator-dubbo/issues) of this repository and believe that this is not a duplicate.
- [ ] I have checked the [FAQ](https://github.com/apache/incubator-dubbo/blob/master/FAQ.md) of this repository and believe that this is not a duplicate.
### Environment
* Dubbo version: 2.7.2
* Operating System version: windows 10
* Java version: 1.8
### Steps to reproduce this issue
1. using generic types(say List<PersonTest<String>> or Map<String, List<PersonTest<String>>>) as method parameters
2. call this RPC method
the similar problem with generic return type has been fixd in #3771
Pls. provide [GitHub address] to reproduce this issue.
### Expected Result
the provider side with receive the correct parameter type
### Actual Result
the actual result is as the following
![image](https://user-images.githubusercontent.com/12162539/55305082-4cf2b680-5481-11e9-8893-3c21a14701a6.png)
and when I trying to do some with it, it will throw exception
If there is an exception, please attach the exception trace:
```
java.lang.ClassCastException: com.alibaba.fastjson.JSONObject cannot be cast to org.apache.dubbo.demo.PersonTest
at java.util.ArrayList.forEach(ArrayList.java:1257)
at org.apache.dubbo.demo.provider.DemoServiceImpl.fastjsonTest1(DemoServiceImpl.java:67)
at org.apache.dubbo.common.bytecode.Wrapper1.invokeMethod(Wrapper1.java)
at org.apache.dubbo.rpc.proxy.javassist.JavassistProxyFactory$1.doInvoke(JavassistProxyFactory.java:47)
at org.apache.dubbo.rpc.proxy.AbstractProxyInvoker.invoke(AbstractProxyInvoker.java:86)
at org.apache.dubbo.config.invoker.DelegateProviderMetaDataInvoker.invoke(DelegateProviderMetaDataInvoker.java:56)
at org.apache.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:56)
at org.apache.dubbo.rpc.filter.ExceptionFilter.invoke(ExceptionFilter.java:63)
at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:73)
at org.apache.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:88)
at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:73)
at org.apache.dubbo.rpc.filter.TimeoutFilter.invoke(TimeoutFilter.java:54)
at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:73)
at org.apache.dubbo.rpc.protocol.dubbo.filter.TraceFilter.invoke(TraceFilter.java:80)
at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:73)
at org.apache.dubbo.rpc.filter.ContextFilter.invoke(ContextFilter.java:79)
at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:73)
at org.apache.dubbo.rpc.filter.GenericFilter.invoke(GenericFilter.java:137)
at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:73)
at org.apache.dubbo.rpc.filter.ClassLoaderFilter.invoke(ClassLoaderFilter.java:38)
at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:73)
at org.apache.dubbo.rpc.filter.EchoFilter.invoke(EchoFilter.java:39)
at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:73)
at org.apache.dubbo.rpc.protocol.dubbo.DubboProtocol$1.reply(DubboProtocol.java:128)
at org.apache.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.handleRequest(HeaderExchangeHandler.java:103)
at org.apache.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.received(HeaderExchangeHandler.java:200)
at org.apache.dubbo.remoting.transport.DecodeHandler.received(DecodeHandler.java:51)
at org.apache.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.run(ChannelEventRunnable.java:57)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
```
[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3779 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] cyejing commented on issue #3779: problem
with generic parameters when using fastjson serialization
Posted by "cyejing (GitHub)" <gi...@apache.org>.
这个打算怎么修复呢? provide端拿到的参数类型是序列化出来的一层Class https://github.com/apache/incubator-dubbo/blob/1df4a21d315421f0f9f101a6bfd6ab8811853e74/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DecodeableRpcInvocation.java#L109
如果可以拿到入参的generic types 就好办了。
还有一种就是开启AutoType的方式,但是希望是服务端和客户端不需要强依赖类型进行序列化。所以才选择用json
你有什么好办法吗?
[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3779 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org