You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2022/12/16 08:41:19 UTC

[GitHub] [dubbo] fl061157 opened a new issue, #11161: dubbo 协议 切换 到 Triple 兼容性问题(序列化方式)

fl061157 opened a new issue, #11161:
URL: https://github.com/apache/dubbo/issues/11161

   * Dubbo version: 3.1.2
   * Java version: 1.8.0_322
   
   
   1. DUBBO 协议原使用序列化方式为 hessin2 , Triple 协议 RPCType:UNARY 也是用  hessin2 .
   2. 拿到 响应的 Response 时候, 发现 序列化成了 父类的实例,查阅代码发现。 
   
   原来使用 DUBBO协议的时候使用的代码如下:
   DecodeableRpcResult
   
   `private void handleValue(ObjectInput in) throws IOException {
           try {
               Type[] returnTypes;
               if (invocation instanceof RpcInvocation) {
                   returnTypes = ((RpcInvocation) invocation).getReturnTypes();
               } else {
                   returnTypes = RpcUtils.getReturnTypes(invocation);
               }
               Object value;
               if (ArrayUtils.isEmpty(returnTypes)) {
                   // This almost never happens?
                   value = in.readObject();
               } else if (returnTypes.length == 1) {
                   value = in.readObject((Class<?>) returnTypes[0]);
               } else {
                   value = in.readObject((Class<?>) returnTypes[0], returnTypes[1]);
               }
               setValue(value);
           } catch (ClassNotFoundException e) {
               rethrow(e);
           }
       }`
   
   通过 响应类的类型做序列化。 ` in.readObject((Class<?>) returnTypes[0], returnTypes[1]);`
   
   但是 在 做 Triple 协议 反序列化时:
   
   默认使用 DefaultMultipleSerialization  做序列化
   
   ` @Override
       public Object deserialize(URL url, String serializeType, String clz, InputStream os) throws IOException, ClassNotFoundException {
           serializeType = convertHessian(serializeType);
           final Serialization serialization = url.getOrDefaultFrameworkModel().getExtensionLoader(Serialization.class).getExtension(serializeType);
           final ObjectInput in = serialization.deserialize(null, os);
           return in.readObject();
       }`
   
   没有使用 响应类的类型 `return in.readObject();`
   
   因此  返回的是 父类, 因此出现异常。 
   
   
   
   
   
   
   
   
   
   
   
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] AlbumenJ commented on issue #11161: dubbo 协议 切换 到 Triple 兼容性问题(序列化方式)

Posted by GitBox <gi...@apache.org>.
AlbumenJ commented on issue #11161:
URL: https://github.com/apache/dubbo/issues/11161#issuecomment-1359437044

   @EarthChen PTAL


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] EarthChen commented on issue #11161: dubbo 协议 切换 到 Triple 兼容性问题(序列化方式)

Posted by GitBox <gi...@apache.org>.
EarthChen commented on issue #11161:
URL: https://github.com/apache/dubbo/issues/11161#issuecomment-1376682233

   https://github.com/apache/dubbo-samples/pull/703


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] EarthChen closed issue #11161: dubbo 协议 切换 到 Triple 兼容性问题(序列化方式)

Posted by GitBox <gi...@apache.org>.
EarthChen closed issue #11161: dubbo 协议 切换 到 Triple 兼容性问题(序列化方式)
URL: https://github.com/apache/dubbo/issues/11161


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] EarthChen commented on issue #11161: dubbo 协议 切换 到 Triple 兼容性问题(序列化方式)

Posted by GitBox <gi...@apache.org>.
EarthChen commented on issue #11161:
URL: https://github.com/apache/dubbo/issues/11161#issuecomment-1368168855

   @fl061157 问一下你这边是具体是什么场景呢,虽然我提了 pr 去修复和 dubbo 的保持一致,但是我本地测试原有的方式似乎也是可以的
   
   ```java
   @Override
   public ParentPojo greetChildPojo(String test) {
       ChildPojo childPojo = new ChildPojo();
       childPojo.setChild(test);
       childPojo.setParent(test);
       return childPojo;
   }
   ```
   
   <img width="894" alt="image" src="https://user-images.githubusercontent.com/20179425/210126397-c14de1f7-a00d-425f-947f-de0d877ca0a0.png">
   
   
   最好可以在sample上提个pr,我们针对pr去修复
   
   https://github.com/apache/dubbo-samples
   
   
   ```
   org.apache.dubbo.sample.tri.api.PojoGreeter
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org