You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "kimmking (via GitHub)" <gi...@apache.org> on 2023/09/28 16:35:00 UTC

[GitHub] [dubbo] kimmking commented on a diff in pull request #13110: feat: Support native steram calls in generic call(#13109)

kimmking commented on code in PR #13110:
URL: https://github.com/apache/dubbo/pull/13110#discussion_r1340412641


##########
dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/GenericFilter.java:
##########
@@ -191,6 +192,26 @@ public Result invoke(Invoker<?> invoker, Invocation inv) throws RpcException {
                                 args.length + " and type is" +
                                 args[0].getClass().getName());
                     }
+                }  else if (ProtocolUtils.isNativeStreamGenericSerialization(generic)) {
+                    for (int i = 0; i < args.length; i++) {
+                        if (byte[].class == args[i].getClass()) {
+                            try (UnsafeByteArrayInputStream is = new UnsafeByteArrayInputStream((byte[]) args[i])) {
+                                args[i] = applicationModel.getExtensionLoader(Serialization.class)
+                                    .getExtension(invoker.getUrl().getParameter(Constants.SERIALIZATION_KEY))
+                                    .deserialize(null, is).readObject(method.getParameterTypes()[i]);
+                            } catch (Exception e) {
+                                throw new RpcException("Deserialize argument [" + (i + 1) + "] failed.", e);
+                            }
+                        } else {
+                            throw new RpcException(
+                                "Generic serialization [" +
+                                    invoker.getUrl().getParameter(Constants.SERIALIZATION_KEY) +
+                                    "] only support message type " +
+                                    byte[].class +
+                                    " and your message type is " +
+                                    args[i].getClass());
+                        }
+                    }

Review Comment:
   ensure data types in runtime by an external filter is more compatible



-- 
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