plusmancn edited a comment on issue #8387: URL: https://github.com/apache/dubbo/issues/8387#issuecomment-895139370
### 5) The cachedWrapperClasses may conflict with initExtension method. ```java // => org.apache.dubbo.common.extension.ExtensionLoader#createExtension private T createExtension(String name, boolean wrap) { // ...... if (wrap) { List<Class<?>> wrapperClassesList = new ArrayList<>(); if (cachedWrapperClasses != null) { wrapperClassesList.addAll(cachedWrapperClasses); // 对包装类进行排序,依赖 @Activate 注解的 order 值,如果缺失则为 0 // 值越大,流程越靠前 wrapperClassesList.sort(WrapperComparator.COMPARATOR); Collections.reverse(wrapperClassesList); } if (CollectionUtils.isNotEmpty(wrapperClassesList)) { for (Class<?> wrapperClass : wrapperClassesList) { // @Wrapper 注解表明,使用该包装器需要什么条件 Wrapper wrapper = wrapperClass.getAnnotation(Wrapper.class); if (wrapper == null || (ArrayUtils.contains(wrapper.matches(), name) && !ArrayUtils.contains(wrapper.mismatches(), name))) { // (T) 向上转型为原始接口类,例如 Protocol // 并对包装类再次执行依赖注入 instance = injectExtension((T) wrapperClass.getConstructor(type).newInstance(instance)); } } } } // 现在我们再看 initExtension 方法,当实例被包装过后,有可能不再是 Lifecycle 实例 // 从严谨的角度来看,职责链和此处的 Hook 方法是冲突的,容易给用户造成不必要的困惑。 initExtension(instance); // ...... } ``` -- 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-unsubscr...@dubbo.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org For additional commands, e-mail: notifications-h...@dubbo.apache.org