Skip to content

Commit

Permalink
Add Logging
Browse files Browse the repository at this point in the history
Now if the ServletRegistration API available message is shown, it will
also be accompanied with a startup warning in the logs.

Closes gh-14221
  • Loading branch information
jzheaux committed Dec 1, 2023
1 parent a98baa7 commit c623303
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
import javax.servlet.ServletRegistration;
import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.context.ApplicationContext;
import org.springframework.http.HttpMethod;
Expand Down Expand Up @@ -75,6 +78,8 @@ public abstract class AbstractRequestMatcherRegistry<C> {
AbstractRequestMatcherRegistry.class.getClassLoader());
}

private final Log logger = LogFactory.getLog(getClass());

protected final void setApplicationContext(ApplicationContext context) {
this.context = context;
}
Expand Down Expand Up @@ -326,6 +331,10 @@ public C requestMatchers(HttpMethod method, String... patterns) {
matchers.add(resolve(ant, mvc, servletContext));
}
else {
this.logger
.warn("The ServletRegistration API was not available at startup time. This may be due to a misconfiguration; "
+ "if you are using AbstractSecurityWebApplicationInitializer, please double-check the recommendations outlined in "
+ "https://docs.spring.io/spring-security/reference/servlet/configuration/java.html#abstractsecuritywebapplicationinitializer-with-spring-mvc");
matchers.add(new DeferredRequestMatcher((request) -> resolve(ant, mvc, request.getServletContext()),
mvc, ant));
}
Expand Down

0 comments on commit c623303

Please sign in to comment.