From 9df068417367cb721cfd925936a956cb67c1785f Mon Sep 17 00:00:00 2001 From: qixiaobo Date: Wed, 10 Jul 2019 21:16:57 +0800 Subject: [PATCH 1/2] Dubbo throws exception when use java serializer issues: https://github.com/apache/dubbo/issues/3951 https://github.com/apache/dubbo/issues/3698 --- .../alibaba/dubbo/rpc/protocol/dubbo/DubboCodec.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboCodec.java b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboCodec.java index b1591918061..8734dc20419 100644 --- a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboCodec.java +++ b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboCodec.java @@ -73,13 +73,12 @@ protected Object decodeBody(Channel channel, InputStream is, byte[] header) thro byte status = header[3]; res.setStatus(status); try { - ObjectInput in = CodecSupport.deserialize(channel.getUrl(), is, proto); if (status == Response.OK) { Object data; if (res.isHeartbeat()) { - data = decodeHeartbeatData(channel, in); + data = decodeHeartbeatData(channel, CodecSupport.deserialize(channel.getUrl(), is, proto)); } else if (res.isEvent()) { - data = decodeEventData(channel, in); + data = decodeEventData(channel, CodecSupport.deserialize(channel.getUrl(), is, proto)); } else { DecodeableRpcResult result; if (channel.getUrl().getParameter( @@ -97,7 +96,7 @@ protected Object decodeBody(Channel channel, InputStream is, byte[] header) thro } res.setResult(data); } else { - res.setErrorMessage(in.readUTF()); + res.setErrorMessage(CodecSupport.deserialize(channel.getUrl(), is, proto).readUTF()); } } catch (Throwable t) { if (log.isWarnEnabled()) { @@ -117,11 +116,10 @@ protected Object decodeBody(Channel channel, InputStream is, byte[] header) thro } try { Object data; - ObjectInput in = CodecSupport.deserialize(channel.getUrl(), is, proto); if (req.isHeartbeat()) { - data = decodeHeartbeatData(channel, in); + data = decodeHeartbeatData(channel, CodecSupport.deserialize(channel.getUrl(), is, proto)); } else if (req.isEvent()) { - data = decodeEventData(channel, in); + data = decodeEventData(channel, CodecSupport.deserialize(channel.getUrl(), is, proto)); } else { DecodeableRpcInvocation inv; if (channel.getUrl().getParameter( From 01c80e5a0ca337bc012cf47f0d2a08f3802d85fb Mon Sep 17 00:00:00 2001 From: qixiaobo Date: Wed, 10 Jul 2019 21:57:15 +0800 Subject: [PATCH 2/2] Dubbo throws exception when use java serializer issues: https://github.com/apache/dubbo/issues/3951 https://github.com/apache/dubbo/issues/3698 fix travis-ci UnusedImports --- .../java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboCodec.java | 1 - 1 file changed, 1 deletion(-) diff --git a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboCodec.java b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboCodec.java index 8734dc20419..3c12448895f 100644 --- a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboCodec.java +++ b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboCodec.java @@ -22,7 +22,6 @@ import com.alibaba.dubbo.common.io.UnsafeByteArrayInputStream; import com.alibaba.dubbo.common.logger.Logger; import com.alibaba.dubbo.common.logger.LoggerFactory; -import com.alibaba.dubbo.common.serialize.ObjectInput; import com.alibaba.dubbo.common.serialize.ObjectOutput; import com.alibaba.dubbo.common.utils.ReflectUtils; import com.alibaba.dubbo.common.utils.StringUtils;