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/07/03 09:55:46 UTC

[GitHub] [dubbo] cheese8 commented on issue #10257: 启动时报java.lang.UnsupportedOperationException导致无法运行

cheese8 commented on issue #10257:
URL: https://github.com/apache/dubbo/issues/10257#issuecomment-1173049846

   > 问题的根源在于org.apache.dubbo.config.spring.util.DubboAnnotationUtils类中的public static Map<String, String> convertParameters(String[] parameters)中的差异,在3.0.6及之前版本ArrayUtils.isEmpty(parameters)为空时直接返回的是null,在3.0.7开始的版本返回的是Collections.emptyMap();
   > 
   > 当dubbo的服务bean的定义时用到了这个方法,见org.apache.dubbo.config.spring.beans.factory.annotation.ServiceAnnotationPostProcessor类的buildServiceBeanDefinition方法 <img alt="Pasted Graphic 4" width="1428" src="https://user-images.githubusercontent.com/421994/177032573-65d2ec96-3d66-478a-8feb-91e5654b263b.png">
   > 
   > 在程序运行时refresh会调用到org.apache.dubbo.config.AbstractConfig的assignProperties方法,此方法又会调用到invokeSetParameters方法,在invokeSetParameters方法中又会调用private static Map<String, String> invokeGetParameters(Class c, Object o)方法,此方法里面有一个method的反射调用,其实最终调用到org.apache.dubbo.config.AbstractMethodConfig的getParameters方法,那么就要看setParameters是何时调用的了, <img alt="image" width="1250" src="https://user-images.githubusercontent.com/421994/177033265-4a26a988-29e3-4fe0-b803-9c0e9c621297.png"> <img alt="image" width="1430" src="https://user-images.githubusercontent.com/421994/177033298-d63e6079-a11d-4f58-b6ba-6e0e5538debb.png"> 通过追踪也就知道问题的症结就在于bean定义时赋值的Collections.emptyMap();导致的。
   > 
   > 因此建议综合考虑org.apache.dubbo.config.spring.util.DubboAnnotationUtils.convertParameters的差异性
   
   返回emptyMap比null好。


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