Skip to content

Servlet Container Beans (i.e. Filter, Servlet, etc) are instantiated too soon #6178

Closed
@rwinch

Description

@rwinch

Spring Boot 1.4.0.M3 (and prior versions) initialize Servlet Filters too eagerly. This can lead to inconsistencies between running tests and integration tests (i.e. spring-projects/spring-data-examples#189). It can also lead to ordering issues when working with AOP (i.e. #2578 behaves differently between test and integration test).

The problem is cause by:

This is not ideal because these Beans might depend on a lot of other Beans (i.e. Servlet initializes all of Spring MVC, Filter initializes Spring Security, etc) and cause all sorts of ordering issues due to the eager initialization of the Beans. It should be noted that while DelegatingFilterProxy is used, the servlet container initializes the DelegatingFilterProxy which in turn initializes the Filter that is marked as a Bean.

As it stands onRefresh initializes every Bean rather than "special Beans" (as is intended).

What is expected is that the Servlet Container Beans would be initialized in finishBeanFactoryInitialization.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: blockerAn issue that is blocking us from releasingtype: bugA general bug

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions