-
Notifications
You must be signed in to change notification settings - Fork 26.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected generic exception in triple #13368
Comments
Can you please provider the error log including exception stack trace? |
Acturally, our method named ExperimentDetailApi.queryForGatewayRoute has only one object param, but in generics there are three params which acturally are the params of GenericService.$invoke.
|
Do you mean that you have defined a service which have the params like |
I have invoked a service with ’GenericService‘ interface. my service has just only one param, that is java.lang.Object. But when I invoked it using GenericService.$invoke("queryForGatewayRoute", null, args), the provider threw an NoSuchMethodExceptio. Because the provider received a request with three params |
@icodening PTAL |
@AlbumenJ @icodening Which version would you fix this issue in ? |
May fixed in #13442 |
When the second parameter of GenericService.$invoke is passed null, version 3.2.7 fills it with the parameter type of $invoke, causing the provider to not be able to find the corresponding method.
Environment
Steps to reproduce this issue
Pls. provide [GitHub address] to reproduce this issue.
Expected Behavior
Return normally
Actual Behavior
The provider cannot find the corresponding method
Cause Analysis:
Use org.apache.dubbo.rpc.protocol.tri.TripleInvoker#invokeUnary to obtain the actual parameter type using
If null is passed, invocation.getArguments()[1] instanceof String[] will not be established, resulting in the actual parameter type returned being a generic parameter type [String, Ljava.lang.String, Ljava.lang.Object]
The request received by the provider is as shown below,
![image](https://private-user-images.githubusercontent.com/7105269/283117759-5f1e7dcd-60be-4eaa-864a-f8290b74a187.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxNTQ5ODAsIm5iZiI6MTcyNjE1NDY4MCwicGF0aCI6Ii83MTA1MjY5LzI4MzExNzc1OS01ZjFlN2RjZC02MGJlLTRlYWEtODY0YS1mODI5MGI3NGExODcucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDkxMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA5MTJUMTUyNDQwWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NzNlNGIxOTdiZWRlOTFhZWQyMjVhMTIyN2E1ZTI0ZTliNjAyOTUwZWFkNTZlOWIwOWI0ZDFkMDQxODFkOTM0MSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.AhBiHXYQTA0MN8Pn_DPcw0IeiSd9kw6-7FJnCwFAEa0)
Environment
Steps to reproduce this issue
Pls. provide [GitHub address] to reproduce this issue.
Expected Behavior
正常返回
Actual Behavior
提供者找不到对应方法
原因分析:
org.apache.dubbo.rpc.protocol.tri.TripleInvoker#invokeUnary 里面使用org.apache.dubbo.rpc.support.RpcUtils#getParameterTypes获取实际参数类型
public static Class[] getParameterTypes(Invocation invocation) { if ($INVOKE.equals(invocation.getMethodName()) && invocation.getArguments() != null && invocation.getArguments().length > 1 && invocation.getArguments()[1] instanceof String[]) { String[] types = (String[]) invocation.getArguments()[1]; if (types == null) { return new Class[0];
}
Class[] parameterTypes = new Class[types.length];
for (int i = 0; i < types.length; i++) {
parameterTypes[i] = ReflectUtils.forName(types[i]);
}
return parameterTypes;
}
return invocation.getParameterTypes();
}
如果传的是null,则 invocation.getArguments()[1] instanceof String[]不会成立,导致返回的实际参数类型泛型的参数类型 [String, Ljava.lang.String, Ljava.lang.Object]
提供者收到的请求如下图,
![image](https://private-user-images.githubusercontent.com/7105269/283117759-5f1e7dcd-60be-4eaa-864a-f8290b74a187.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxNTQ5ODAsIm5iZiI6MTcyNjE1NDY4MCwicGF0aCI6Ii83MTA1MjY5LzI4MzExNzc1OS01ZjFlN2RjZC02MGJlLTRlYWEtODY0YS1mODI5MGI3NGExODcucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDkxMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA5MTJUMTUyNDQwWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NzNlNGIxOTdiZWRlOTFhZWQyMjVhMTIyN2E1ZTI0ZTliNjAyOTUwZWFkNTZlOWIwOWI0ZDFkMDQxODFkOTM0MSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.AhBiHXYQTA0MN8Pn_DPcw0IeiSd9kw6-7FJnCwFAEa0)
The text was updated successfully, but these errors were encountered: