- 
        Couldn't load subscription status. 
- Fork 38.8k
Description
Paul Tomlin opened SPR-9996 and commented
Referring to org.springframework.web.context.ContextLoader
JavaDocs for ContextLoader#ContextLoader(WebApplicationContext) state:
The context may or may not yet be refreshed. If it (a) is an implementation of ConfigurableWebApplicationContext and (b) has not already been refreshed (the recommended approach), then the following will occur:
- If the given context has not already been assigned an id, one will be assigned to it
- ServletContext and ServletConfig objects will be delegated to the application context
- customizeContext(javax.servlet.ServletContext, org.springframework.web.context.ConfigurableWebApplicationContext) will be called
- Any ApplicationContextInitializers specified through the "contextInitializerClasses" init-param will be applied.
- refresh() will be called
If the context has already been refreshed or does not implement ConfigurableWebApplicationContext, none of the above will occur under the assumption that the user has performed these actions (or not) per his or her specific needs.
However, it appears that a context provided to the constructor which has already been refreshed, is again refreshed.
ContextLoader#initWebApplicationContext(ServletContext) checks if the context is a ConfigurableWebApplicationContext but no check appears to be made for ConfigurableApplicationContext#isActive(), or Lifecycle#isRunning()
Affects: 3.1.3
Issue Links:
- WebApplicationInitializer with AnnotationConfigWebApplicationContext parent gets reset to null by ContextLoaderListener [SPR-9591] #14225 WebApplicationInitializer with AnnotationConfigWebApplicationContext parent gets reset to null by ContextLoaderListener
Referenced from: commits 701c5f1, b720804
Backported to: 3.1.4