You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "gMan1990 (GitHub)" <gi...@apache.org> on 2018/11/30 05:49:18 UTC
[GitHub] [incubator-dubbo] gMan1990 opened issue #2855: 2.6.5问题,ReferenceAnnotationBeanPostProcessor$ReferenceBeanInvocationHandler#bean
* dubbo: 2.6.5
* 测试,所以提供者和消费者在同一个jvm里
------
ReferenceBeanInvocationHandler的invoke就是消费者方法执行后会调用到的方法,它有个init方法用来初始化bean字段,这个方法有两处调用:
1. https://github.com/apache/incubator-dubbo/blob/38e0f15be33a5edb35b45d2c5d7c6be753bdd888/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/beans/factory/annotation/ReferenceAnnotationBeanPostProcessor.java#L128
```
private InvocationHandler buildInvocationHandler(String referencedBeanName, ReferenceBean referenceBean) {
ReferenceBeanInvocationHandler handler = localReferenceBeanInvocationHandlerCache.get(referencedBeanName);
if (handler == null) {
handler = new ReferenceBeanInvocationHandler(referenceBean);
}
if (applicationContext.containsBean(referencedBeanName)) { // Is local @Service Bean or not ?
// ReferenceBeanInvocationHandler's initialization has to wait for current local @Service Bean has been exported.
localReferenceBeanInvocationHandlerCache.put(referencedBeanName, handler);
} else {
// Remote Reference Bean should initialize immediately
handler.init();
}
return handler;
}
```
2. https://github.com/apache/incubator-dubbo/blob/38e0f15be33a5edb35b45d2c5d7c6be753bdd888/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/beans/factory/annotation/ReferenceAnnotationBeanPostProcessor.java#L230
```
private void initReferenceBeanInvocationHandler(ServiceBean serviceBean) {
String serviceBeanName = serviceBean.getBeanName();
// Remove ServiceBean when it's exported
ReferenceBeanInvocationHandler handler = localReferenceBeanInvocationHandlerCache.remove(serviceBeanName);
// Initialize
if (handler != null) {
handler.init();
}
}
```
------
因为是测试所以:1处走的是```if (applicationContext.containsBean(referencedBeanName))```里面,不会调用```handler.init();```,2处我断点到handler都是null所以也不会调用```handler.init();```
所以那个bean字段都是null。然后执行invoke方法就是:
```
java.lang.NullPointerException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.alibaba.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor$ReferenceBeanInvocationHandler.invoke(ReferenceAnnotationBeanPostProcessor.java:159)
```
[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2855 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] tswstarplanet commented on issue #2855: 2.6.5问题,ReferenceAnnotationBeanPostProcessor$ReferenceBeanInvocationHandler#bean
Posted by "tswstarplanet (GitHub)" <gi...@apache.org>.
能提供demo吗?我自己复现没出现这个问题
[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2855 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] flyer5200 commented on issue #2855: 2.6.5问题,ReferenceAnnotationBeanPostProcessor$ReferenceBeanInvocationHandler#bean
Posted by "flyer5200 (GitHub)" <gi...@apache.org>.
> Thanks for your report, We also found this issue, will be fixed on 2.6.6
This problem still exists in 2.6.6 or 2.7.0, please confirm!
[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2855 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] mercyblitz commented on issue #2855: 2.6.5问题,ReferenceAnnotationBeanPostProcessor$ReferenceBeanInvocationHandler#bean
Posted by "mercyblitz (GitHub)" <gi...@apache.org>.
@gMan1990
Actually, all services annotated `@Service` should be exported before `ReferenceBean#afterPropertiesSet()` method executation.
[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2855 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] gMan1990 commented on issue #2855: 2.6.5问题,ReferenceAnnotationBeanPostProcessor$ReferenceBeanInvocationHandler#bean
Posted by "gMan1990 (GitHub)" <gi...@apache.org>.
@tswstarplanet 没有,是com.alibaba.dubbo.config.ReferenceConfig#createProxy方法自己查找提供者的
[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2855 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] mercyblitz commented on issue #2855: 2.6.5问题,ReferenceAnnotationBeanPostProcessor$ReferenceBeanInvocationHandler#bean
Posted by "mercyblitz (GitHub)" <gi...@apache.org>.
The duplicated issue : https://github.com/apache/incubator-dubbo/issues/3429
[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2855 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] gMan1990 commented on issue #2855: 2.6.5问题,ReferenceAnnotationBeanPostProcessor$ReferenceBeanInvocationHandler#bean
Posted by "gMan1990 (GitHub)" <gi...@apache.org>.
@tswstarplanet
> ReferenceBeanInvocationHandler的invoke就是消费者方法执行后会调用到的方法,它有个init方法用来初始化bean字段,这个方法有两处调用
你先看下这个是不是两处调用,每处调用debug下,看是否和我说的一样:
> 因为是测试所以:1处走的是if (applicationContext.containsBean(referencedBeanName))里面,不会调用handler.init();,2处我断点到handler都是null所以也不会调用handler.init();
> 所以那个bean字段都是null
然后执行invoke方法,看那个bean字段是否为null
[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2855 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] mercyblitz closed issue #2855: 2.6.5问题,ReferenceAnnotationBeanPostProcessor$ReferenceBeanInvocationHandler#bean
Posted by "mercyblitz (GitHub)" <gi...@apache.org>.
[ issue closed by mercyblitz ]
[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2855 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] tswstarplanet commented on issue #2855: 2.6.5问题,ReferenceAnnotationBeanPostProcessor$ReferenceBeanInvocationHandler#bean
Posted by "tswstarplanet (GitHub)" <gi...@apache.org>.
请问是protocol配置成injvm吗?
[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2855 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] mercyblitz commented on issue #2855: 2.6.5问题,ReferenceAnnotationBeanPostProcessor$ReferenceBeanInvocationHandler#bean
Posted by "mercyblitz (GitHub)" <gi...@apache.org>.
Thanks for your report, We also found this issue, will be fixed on 2.6.6
[ Full content available at: https://github.com/apache/incubator-dubbo/issues/2855 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org