File tree Expand file tree Collapse file tree
spring-web/src/main/java/org/springframework/web/method Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616
1717package org .springframework .web .method ;
1818
19- import java .util .Arrays ;
19+ import java .util .ArrayList ;
2020import java .util .List ;
21- import java .util .stream .Collectors ;
2221
2322import org .springframework .beans .factory .BeanFactory ;
2423import org .springframework .beans .factory .BeanFactoryUtils ;
4241 * @author Rossen Stoyanchev
4342 * @author Brian Clozel
4443 * @author Juergen Hoeller
44+ * @author Sam Brannen
4545 * @since 3.2
4646 */
4747public 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 ) {
You can’t perform that action at this time.
0 commit comments