You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "yxc023 (GitHub)" <gi...@apache.org> on 2019/03/19 16:43:45 UTC

[GitHub] [incubator-dubbo] yxc023 opened issue #3695: @Reference field can't refer its' @Service Bean in same JVM from v2.6.6

### Environment

* Dubbo version: 2.6.6
* Operating System version: xxx
* Java version: xxx

### Steps to reproduce this issue

1. xxx
2. xxx
3. xxx

Pls. provide [GitHub address] to reproduce this issue.

### Expected Result

我用单测实测自己项目内部提供的 dubbo service,

在单测类中使用 `@Reference` 注解引入服务接口.

启动时报错, 无法获取 provider

### Actual Result

在 2.6.5 之前的代码里, 一个项目中的 `@Service` 和 `@Reference` 所生成的 bean, 名字都是以 `ServiceBean:` 开头, 那么在 `ReferenceAnnotationBeanPostProcessor.buildInvocationHandler()` 中

```
        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();
        }
```
会进行判断, 如果是内部 service, 则 reference 会等待 service export 之后再 init.

而在 2.6.6 中, 上面代码失效了.

原因在于 2.6.6 使用了 `AnnotationBeanNameBuilder` 来给 service 和 reference 命名, 化分了不同前缀, 导致同一个项目里 reference 不能等待 service export 之后再去获取.


[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3695 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [incubator-dubbo] mercyblitz commented on issue #3695: @Reference field can't refer its' @Service Bean in same JVM from v2.6.6

Posted by "mercyblitz (GitHub)" <gi...@apache.org>.
This's an issue in 2.6.6

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3695 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [incubator-dubbo] cvictory commented on issue #3695: @Reference field can't refer its' @Service Bean in same JVM from v2.6.6

Posted by "cvictory (GitHub)" <gi...@apache.org>.
@mercyblitz  can you have a look to this issue ?

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3695 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [incubator-dubbo] kexianjun commented on issue #3695: @Reference field can't refer its' @Service Bean in same JVM from v2.6.6

Posted by "kexianjun (GitHub)" <gi...@apache.org>.
I have reproduce this issue

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3695 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [incubator-dubbo] kexianjun commented on issue #3695: @Reference field can't refer its' @Service Bean in same JVM from v2.6.6

Posted by "kexianjun (GitHub)" <gi...@apache.org>.
I'll try to reproduce this problem

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3695 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [incubator-dubbo] yxc023 commented on issue #3695: @Reference field can't refer its' @Service Bean in same JVM from v2.6.6

Posted by "yxc023 (GitHub)" <gi...@apache.org>.
可能是个个性化需求, 我先手动 export 解决了.

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3695 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org