You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by li...@apache.org on 2019/12/11 12:16:30 UTC

[dubbo] branch 2.6.x updated: Fix null attachment issue when consumer use generic (#5390)

This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch 2.6.x
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/2.6.x by this push:
     new 89b213f  Fix null attachment issue when consumer use generic (#5390)
89b213f is described below

commit 89b213f78d93bc5607552c2d8edb8a4035a81528
Author: Shadow <sh...@gmail.com>
AuthorDate: Wed Dec 11 20:16:20 2019 +0800

    Fix null attachment issue when consumer use generic (#5390)
    
    Fix #5389
---
 .../main/java/com/alibaba/dubbo/rpc/filter/GenericFilter.java    | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/GenericFilter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/GenericFilter.java
index 8404a99..b8d9d87 100644
--- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/GenericFilter.java
+++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/GenericFilter.java
@@ -114,21 +114,24 @@ public class GenericFilter implements Filter {
                         && !(result.getException() instanceof GenericException)) {
                     return new RpcResult(new GenericException(result.getException()));
                 }
+                RpcResult rpcResult;
                 if (ProtocolUtils.isJavaGenericSerialization(generic)) {
                     try {
                         UnsafeByteArrayOutputStream os = new UnsafeByteArrayOutputStream(512);
                         ExtensionLoader.getExtensionLoader(Serialization.class)
                                 .getExtension(Constants.GENERIC_SERIALIZATION_NATIVE_JAVA)
                                 .serialize(null, os).writeObject(result.getValue());
-                        return new RpcResult(os.toByteArray());
+                        rpcResult = new RpcResult(os.toByteArray());
                     } catch (IOException e) {
                         throw new RpcException("Serialize result failed.", e);
                     }
                 } else if (ProtocolUtils.isBeanGenericSerialization(generic)) {
-                    return new RpcResult(JavaBeanSerializeUtil.serialize(result.getValue(), JavaBeanAccessor.METHOD));
+                    rpcResult = new RpcResult(JavaBeanSerializeUtil.serialize(result.getValue(), JavaBeanAccessor.METHOD));
                 } else {
-                    return new RpcResult(PojoUtils.generalize(result.getValue()));
+                    rpcResult = new RpcResult(PojoUtils.generalize(result.getValue()));
                 }
+                rpcResult.setAttachments(result.getAttachments());
+                return rpcResult;
             } catch (NoSuchMethodException e) {
                 throw new RpcException(e.getMessage(), e);
             } catch (ClassNotFoundException e) {