序列化之异常

背景

再见异常~~~

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method reqPartInfoByVinWithRegionNames in the service com.f6car.ids.dos.api.service.MjApiServ ice. Tried 3 times of the providers [10.25.24.204:30883] (1/1) from the registry 10.29.24.84:2181 on the consumer 10.25.24.205 using the dubbo version 2.5.3. Last error is: Failed to invoke remote method: reqPartInfoByVinWithRegionNames, provider: dubbo://10.25.24.204:30883/com.f6car.ids.dos.api.ser vice.MjApiService?anyhost=true&application=f6-open-api&check=false&default.group=f6-product&default.owner=qixiaobo&default.timeout=10000&dubbo=2.5.3&g roup=f6-product&interface=com.f6car.ids.dos.api.service.MjApiService&methods=reqVinParse,reqPartsViaImage,reqPartInfoByVinWithRegionNames,reqPartImage &pid=8842&reference.filter=clientInfoConsumer&revision=0.0.1-SNAPSHOT&serialization=java&side=consumer&timestamp=1527131646226, cause: java.io.Invalid ClassException: com.f6car.ids.dos.exception.ServiceException; local class incompatible: stream classdesc serialVersionUID = -2409543060112980569, loca l class serialVersionUID = -7355151053121969738
32 java.io.InvalidClassException: com.f6car.ids.dos.exception.ServiceException; local class incompatible: stream classdesc serialVersionUID = -2409543060 112980569, local class serialVersionUID = -7355151053121969738
33 at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:617)
34 at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1622)
35 at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1517)
36 at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1771)
37 at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350)
38 at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370)
39 at com.alibaba.dubbo.common.serialize.support.java.JavaObjectInput.readObject(JavaObjectInput.java:75)
40 at com.alibaba.dubbo.rpc.protocol.dubbo.DecodeableRpcResult.decode(DecodeableRpcResult.java:92)
41 at com.alibaba.dubbo.rpc.protocol.dubbo.DecodeableRpcResult.decode(DecodeableRpcResult.java:109)
42 at com.alibaba.dubbo.rpc.protocol.dubbo.DubboCodec.decodeBody(DubboCodec.java:97)
43 at com.alibaba.dubbo.remoting.exchange.codec.ExchangeCodec.decode(ExchangeCodec.java:126)
44 at com.alibaba.dubbo.remoting.exchange.codec.ExchangeCodec.decode(ExchangeCodec.java:87)
45 at com.alibaba.dubbo.rpc.protocol.dubbo.DubboCountCodec.decode(DubboCountCodec.java:46)
46 at com.alibaba.dubbo.remoting.transport.netty.NettyCodecAdapter$InternalDecoder.messageReceived(NettyCodecAdapter.java:134)
47 at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:80)
48 at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
49 at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559)
50 at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:274)
51 at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:261)

乍看就是序列化id没有填写~

可是问了对应的开发 对方信誓旦旦 绝对都加了序列化Id 【当时在该对应的类中增加了属性 而其他调用的地方在调用之后报错了】

恩 这是个很有意思的问题~~~为何出现这种错误了呢???

分析

决定来剖析一下现场~

小伙伴声称其修改了该类

7211702bdf711b7fdfc1b9897a45ca97f65.jpg

0eb98c0121bcf5ca567e52964361b66885d.jpg

哈?还真的有序列化Id

不急我们还有一个类~

9ca5f4f3ecb3aadb051e8ef2cb7731d6ec7.jpg

还暴露了一个事实~这个类是我加的[/(ㄒoㄒ)/~~]…… 不解释 错就要认~

所以归根及底 还是序列化id没加惹的祸~并且很明显报错的时候也提示了

1
com.f6car.ids.dos.exception.ServiceException; local class incompatible: stream classdesc serialVersionUID = -2409543060112980569, loca     l class serialVersionUID = -7355151053121969738

好的习惯从我做起

总结

小伙伴通过更换jar版本完成了序列化id的统一 同时也不会再次出错了 不过该处还是存在隐患。

另外 希望发现这种和自己设想不一样的地方要心存疑惑~ 深挖下去或许有坑~