Skip to content

Commit 2759b4b

Browse files
committed
Avoid use of Stream API in ControllerAdviceBean
1 parent d5554d5 commit 2759b4b

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616

1717
package org.springframework.web.method;
1818

19-
import java.util.Arrays;
19+
import java.util.ArrayList;
2020
import java.util.List;
21-
import java.util.stream.Collectors;
2221

2322
import org.springframework.beans.factory.BeanFactory;
2423
import org.springframework.beans.factory.BeanFactoryUtils;
@@ -42,6 +41,7 @@
4241
* @author Rossen Stoyanchev
4342
* @author Brian Clozel
4443
* @author Juergen Hoeller
44+
* @author Sam Brannen
4545
* @since 3.2
4646
*/
4747
public class ControllerAdviceBean implements Ordered {
@@ -186,10 +186,13 @@ public String toString() {
186186
* instances.
187187
*/
188188
public static List<ControllerAdviceBean> findAnnotatedBeans(ApplicationContext context) {
189-
return Arrays.stream(BeanFactoryUtils.beanNamesForTypeIncludingAncestors(context, Object.class))
190-
.filter(name -> context.findAnnotationOnBean(name, ControllerAdvice.class) != null)
191-
.map(name -> new ControllerAdviceBean(name, context))
192-
.collect(Collectors.toList());
189+
List<ControllerAdviceBean> adviceBeans = new ArrayList<>();
190+
for (String name : BeanFactoryUtils.beanNamesForTypeIncludingAncestors(context, Object.class)) {
191+
if (context.findAnnotationOnBean(name, ControllerAdvice.class) != null) {
192+
adviceBeans.add(new ControllerAdviceBean(name, context));
193+
}
194+
}
195+
return adviceBeans;
193196
}
194197

195198
private static int initOrderFromBean(Object bean) {

0 commit comments

Comments
 (0)