4141import org .springframework .aop .scope .ScopedProxyUtils ;
4242import org .springframework .beans .factory .ListableBeanFactory ;
4343import org .springframework .beans .factory .support .BeanDefinitionRegistry ;
44+ import org .springframework .core .Ordered ;
4445import org .springframework .core .annotation .AnnotationAwareOrderComparator ;
4546import org .springframework .core .annotation .Order ;
4647import org .springframework .util .Assert ;
@@ -198,20 +199,18 @@ private <T, B extends T> void addAsRegistrationBean(ListableBeanFactory beanFact
198199 }
199200
200201 private int getOrder (Object value ) {
201- return new AnnotationAwareOrderComparator () {
202- @ Override
203- public int getOrder (Object obj ) {
204- return super .getOrder (obj );
205- }
206- }.getOrder (value );
202+ Integer order = findOrder (value );
203+ return (order != null ) ? order : Ordered .LOWEST_PRECEDENCE ;
207204 }
208205
209206 private Integer findOrder (Object value ) {
210207 return new AnnotationAwareOrderComparator () {
208+
211209 @ Override
212210 public Integer findOrder (Object obj ) {
213211 return super .findOrder (obj );
214212 }
213+
215214 }.findOrder (value );
216215 }
217216
@@ -318,9 +317,7 @@ private void configureFromAnnotation(ServletRegistrationBean<Servlet> bean, Serv
318317 bean .setAsyncSupported (registration .asyncSupported ());
319318 bean .setIgnoreRegistrationFailure (registration .ignoreRegistrationFailure ());
320319 bean .setLoadOnStartup (registration .loadOnStartup ());
321- if (registration .urlMappings ().length > 0 ) {
322- bean .setUrlMappings (Arrays .asList (registration .urlMappings ()));
323- }
320+ bean .setUrlMappings (Arrays .asList (registration .urlMappings ()));
324321 }
325322
326323 }
@@ -363,12 +360,8 @@ private void configureFromAnnotation(FilterRegistrationBean<Filter> bean, Filter
363360 }
364361 bean .setIgnoreRegistrationFailure (registration .ignoreRegistrationFailure ());
365362 bean .setMatchAfter (registration .matchAfter ());
366- if (registration .servletNames ().length > 0 ) {
367- bean .setServletNames (Arrays .asList (registration .servletNames ()));
368- }
369- if (registration .urlPatterns ().length > 0 ) {
370- bean .setUrlPatterns (Arrays .asList (registration .urlPatterns ()));
371- }
363+ bean .setServletNames (Arrays .asList (registration .servletNames ()));
364+ bean .setUrlPatterns (Arrays .asList (registration .urlPatterns ()));
372365 }
373366
374367 }
@@ -387,6 +380,9 @@ public RegistrationBean createRegistrationBean(String beanName, EventListener so
387380
388381 }
389382
383+ /**
384+ * Tracks seen initializers.
385+ */
390386 private static final class Seen {
391387
392388 private final Map <Class <?>, Set <Object >> seen = new HashMap <>();
0 commit comments