-
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
Dubbo 2.7.8及以上判断Map类型的逻辑有误 #8212
Comments
Hi, how can we reproduce it, could you provide a demo help to reproduce it, thanks. |
this is a dubbo-demo, please put it to dubbo project directory. |
We will see it later, thanks. |
1.创建自定义TypeBuilder
|
This was referenced Mar 29, 2022
Closed
Merged
Merged
chickenlj
pushed a commit
that referenced
this issue
Apr 1, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Environment
Steps to reproduce this issue
class Abc< Str > extends HashMap<String,Object>{
....
}
这种用法很常见
MapTypeBuilder.java此处代码建议修改如下:
即:先判断此类是否实现了Map接口或其子接口,如果实现了,则必须要求有两个泛型参数
否则,需要检查其父类,并将其父类的泛型参数加入到Cache中来。
if (actualTypeArgsLength != 2) {
for (Class c : clazz.getInterfaces()){ if (Map.class.isAssignableFrom(c)){ throw new IllegalArgumentException(MessageFormat.format( "[ServiceDefinitionBuilder] Map type [{0}] with unexpected amount of arguments [{1}]." + Arrays.toString(actualTypeArgs), type, actualTypeArgs)); } } } boolean checkSuper = true; for (Class c : clazz.getInterfaces()){
if (Map.class.isAssignableFrom(c)){
checkSuper = false;
break;
}
}
if (checkSuper) {
Class<?> cl = clazz.getSuperclass();
Type t = clazz.getGenericSuperclass();
build(t, cl, typeCache);
}
Pls. provide [GitHub address] to reproduce this issue.
Expected Result
What do you expected from the above steps?
Actual Result
What actually happens?
If there is an exception, please attach the exception trace:
The text was updated successfully, but these errors were encountered: