Description
See spring-projects/spring-boot#25113 for more context.
ResourceUrlProvider
is listening on ContextRefreshedEvent
to detect automatically instances of SimpleUrlHandlerMapping
and use them for writing URLs to resources. Once handlers are detected the provider locks itself from further modifications.
With a parent/child context setup and under specific conditions due to ordering, the ResourceUrlProvider
might receive a ContextRefreshedEvent
from a child context first, thus detecting the wrong set of handlers and ignoring the expected ContextRefreshedEvent
once all components are ready in the current context.
We must ensure that ResourceUrlProvider
only considers events sent by the current context - this is a common pattern in other parts of Spring Framework.