Skip to content
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

获取自动激活的扩展接口实现类后的排序算法问题 #3390

Closed
2 tasks
dongYES opened this issue Jan 30, 2019 · 7 comments
Closed
2 tasks

获取自动激活的扩展接口实现类后的排序算法问题 #3390

dongYES opened this issue Jan 30, 2019 · 7 comments

Comments

@dongYES
Copy link

dongYES commented Jan 30, 2019

  • I have searched the issues of this repository and believe that this is not a duplicate.
  • I have checked the FAQ 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)。

@CrazyHZM
Copy link
Member

I agree with you, can you submit a pr to fix it?

@dongYES
Copy link
Author

dongYES commented Jan 30, 2019

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属性。

@CrazyHZM
Copy link
Member

是的 在最新发布的2.7.0加上了@deprecated,在新版本里面这个不再是问题。

@dongYES
Copy link
Author

dongYES commented Jan 30, 2019

是的 在最新发布的2.7.0加上了@deprecated,在新版本里面这个不再是问题。

那这个现在怎么说

@CrazyHZM
Copy link
Member

CrazyHZM commented Jan 30, 2019

对于第二个问题我觉得同时去实现两个spi接口的场景是什么

@dongYES
Copy link
Author

dongYES commented Jan 31, 2019

对于第二个问题我觉得同时去实现两个spi接口的场景是什么

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

@beiwei30
Copy link
Member

beiwei30 commented Feb 2, 2019

#3412 and #3418 fixed the issue.

@beiwei30 beiwei30 closed this as completed Feb 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants