Avoid reinitializing dispatcher servlet on refresh#8974
Open
frhack wants to merge 1 commit into
Open
Conversation
The CAS configuration refresh listener eagerly resolves beans after refresh, but it should not manually initialize the DispatcherServlet. Calling DispatcherServlet.init() outside the servlet container can fail because no ServletConfig is available. This surfaced downstream in Apache Syncope WA as SYNCOPE-1758: https://issues.apache.org/jira/browse/SYNCOPE-1758
|
Thank you so much for opening your first pull request here! |
This was referenced May 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The CAS configuration refresh listener eagerly resolves application context beans after refresh, but it also special-cases the
dispatcherServletbean and manually callsDispatcherServlet.init().That call can run outside the servlet container lifecycle, where no
ServletConfigis available. This may surface as aNullPointerExceptionduring refresh.This was observed downstream in Apache Syncope WA:
https://issues.apache.org/jira/browse/SYNCOPE-1758
Root Cause
DefaultCasConfigurationEventListener#initializeBeansEagerly()currently:dispatcherServletDispatcherServlet.classservlet.init()The refresh listener should eagerly resolve beans as needed, but it should not manually initialize Spring MVC's
DispatcherServlet. The servlet container/Spring Boot web lifecycle should own that initialization.Changes
This removes the special-case reinitialization of Spring's
DispatcherServletfrom the CAS configuration refresh listener.The listener still eagerly resolves all beans after refresh, but it no longer calls
DispatcherServlet.init()manually.References
Checklist
masterTests
JAVA_HOME=/tmp/jdk25 ../../gradlew --no-daemon testCasConfiguration --tests org.apereo.cas.support.events.listener.CasConfigurationEventListenerTests