You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "dongYES (GitHub)" <gi...@apache.org> on 2019/01/30 02:43:34 UTC

[GitHub] [incubator-dubbo] dongYES opened issue #3390: 获取自动激活的扩展接口实现类后的排序算法问题

- [ ] I have searched the [issues](https://github.com/apache/incubator-dubbo/issues) of this repository and believe that this is not a duplicate.
- [ ] I have checked the [FAQ](https://github.com/apache/incubator-dubbo/blob/master/FAQ.md) of this repository and believe that this is not a duplicate.

### Environment

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

**问题:**
排序会出现问题
com.alibaba.dubbo.common.extension.support.ActivateComparator 这个比较器在这种场景下的排序会出现问题。

**现象:**
扩展接口的实现类实现了多个接口,其中包括当前SPI接口,还有其它接口,如果实现类实现接口的顺序第一个不是SPI接口,则排序是错误的。

**原因:**
因为ActivateComparator 代码的表逻辑判定是第一个必须是SPI接口---》o1.getClass().getInterfaces()[0].isAnnotationPresent(SPI.class)。



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

[GitHub] [incubator-dubbo] beiwei30 commented on issue #3390: 获取自动激活的扩展接口实现类后的排序算法问题

Posted by "beiwei30 (GitHub)" <gi...@apache.org>.
#3412 and #3418 fixed the issue.

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


[GitHub] [incubator-dubbo] CrazyHZM commented on issue #3390: 获取自动激活的扩展接口实现类后的排序算法问题

Posted by "CrazyHZM (GitHub)" <gi...@apache.org>.
对于第二个问题我觉得同时去实现两个spi接口的场景是什么

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

[GitHub] [incubator-dubbo] CrazyHZM commented on issue #3390: 获取自动激活的扩展接口实现类后的排序算法问题

Posted by "CrazyHZM (GitHub)" <gi...@apache.org>.
是的 在最新发布的2.7.0加上了@Deprecated,在新版本里面这个不再是问题。

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

[GitHub] [incubator-dubbo] CrazyHZM commented on issue #3390: 获取自动激活的扩展接口实现类后的排序算法问题

Posted by "CrazyHZM (GitHub)" <gi...@apache.org>.
对于第二个问题我觉得同事去实现两个spi接口的场景是什么

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

[GitHub] [incubator-dubbo] CrazyHZM commented on issue #3390: 获取自动激活的扩展接口实现类后的排序算法问题

Posted by "CrazyHZM (GitHub)" <gi...@apache.org>.
I agree with you, can you submit a pr to fix it?

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


[GitHub] [incubator-dubbo] dongYES commented on issue #3390: 获取自动激活的扩展接口实现类后的排序算法问题

Posted by "dongYES (GitHub)" <gi...@apache.org>.
> I agree with you, can you submit a pr to fix it?

其实还有一种情况,就是实现类都实现了两个相同的SPI接口,这样的话,应该需要将接口类型传进到ActivateComparator 中作为属性保存,不然不知道该选哪个SPI接口获取ExtensionLoader。所以就不能使用ActivateComparator 类内部的静态变量COMPARATOR,需要每次排序都要通过创建对象的方式进行比较,并将SPI接口class类型传进去。不知道我讲的符不符合规则?
谢谢!


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

[GitHub] [incubator-dubbo] dongYES commented on issue #3390: 获取自动激活的扩展接口实现类后的排序算法问题

Posted by "dongYES (GitHub)" <gi...@apache.org>.
> 是的 在最新发布的2.7.0加上了@deprecated,在新版本里面这个不再是问题。

那这个现在怎么说

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

[GitHub] [incubator-dubbo] dongYES commented on issue #3390: 获取自动激活的扩展接口实现类后的排序算法问题

Posted by "dongYES (GitHub)" <gi...@apache.org>.
> 对于第二个问题我觉得同时去实现两个spi接口的场景是什么

第二个问题,我目前没有遇到过这个场景,那我就只对第一个问题提pr了。第二个问题忽略。

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

[GitHub] [incubator-dubbo] dongYES commented on issue #3390: 获取自动激活的扩展接口实现类后的排序算法问题

Posted by "dongYES (GitHub)" <gi...@apache.org>.
> I agree with you, can you submit a pr to fix it?

其实还有一种情况,就是实现类都实现了两个相同的SPI接口,这样的话,应该需要将接口类型传进到ActivateComparator 中作为属性保存,不然不知道该选哪个SPI接口获取ExtensionLoader。所以就不能使用ActivateComparator 类内部的静态变量COMPARATOR,需要每次排序都要通过创建对象的方式进行比较,并将SPI接口class类型传进去。不知道我讲的符不符合规则?
谢谢!
我看了2.7.0好像要把before和after将要废弃了,全部依赖于order属性。

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

[GitHub] [incubator-dubbo] beiwei30 closed issue #3390: 获取自动激活的扩展接口实现类后的排序算法问题

Posted by "beiwei30 (GitHub)" <gi...@apache.org>.
[ issue closed by beiwei30 ]

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