chickenlj commented on a change in pull request #9391:
URL: https://github.com/apache/dubbo/pull/9391#discussion_r769318460



##########
File path: 
dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java
##########
@@ -771,13 +772,15 @@ private T createExtension(String name, boolean wrap) {
                 }
 
                 if (CollectionUtils.isNotEmpty(wrapperClassesList)) {
-                    for (Class<?> wrapperClass : wrapperClassesList) {
-                        Wrapper wrapper = 
wrapperClass.getAnnotation(Wrapper.class);
-                        if (wrapper == null
-                            || (ArrayUtils.contains(wrapper.matches(), name) 
&& !ArrayUtils.contains(wrapper.mismatches(), name))) {
-                            instance = injectExtension((T) 
wrapperClass.getConstructor(type).newInstance(instance));
-                            instance = 
postProcessAfterInitialization(instance, name);
-                        }
+                    wrapperClassesList = 
wrapperClassesList.stream().filter(wrapperClz -> {
+                        Wrapper wrapper = 
wrapperClz.getAnnotation(Wrapper.class);
+                        return (wrapper == null) ||
+                            ((ArrayUtils.isEmpty(wrapper.matches()) || 
ArrayUtils.contains(wrapper.matches(), name)) &&
+                                !ArrayUtils.contains(wrapper.mismatches(), 
name));
+                    }).collect(Collectors.toList());
+                    for (Class<?> wrapperClz : wrapperClassesList) {
+                        instance = injectExtension((T) 
wrapperClz.getConstructor(type).newInstance(instance));
+                        instance = postProcessAfterInitialization(instance, 
name);

Review comment:
       I think streaming is not a good option used here. Normal for iterating 
can be more memory efficient while clear enough.




-- 
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

Reply via email to