Use bean name for servlet and filter registrations if name is not set
If the name is set, it is used. If not, the bean name is used. If that's not set, the convention based name is taken. Registration failures now throw an IllegalStateException instead of being logged. DynamicRegistrationBean.setIgnoreRegistrationFailure can be used to restore the old behavior. See gh-33911
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -144,6 +144,7 @@ public class JerseyAutoConfiguration implements ServletContextAware {
|
||||
addInitParameters(registration);
|
||||
registration.setName(getServletRegistrationName());
|
||||
registration.setLoadOnStartup(this.jersey.getServlet().getLoadOnStartup());
|
||||
registration.setIgnoreRegistrationFailure(true);
|
||||
return registration;
|
||||
}
|
||||
|
||||
|
||||
@@ -501,7 +501,10 @@ class ServletWebServerFactoryAutoConfigurationTests {
|
||||
|
||||
@Bean(name = DispatcherServletAutoConfiguration.DEFAULT_DISPATCHER_SERVLET_REGISTRATION_BEAN_NAME)
|
||||
ServletRegistrationBean<DispatcherServlet> dispatcherRegistration(DispatcherServlet dispatcherServlet) {
|
||||
return new ServletRegistrationBean<>(dispatcherServlet, "/app/*");
|
||||
ServletRegistrationBean<DispatcherServlet> registration = new ServletRegistrationBean<>(dispatcherServlet,
|
||||
"/app/*");
|
||||
registration.setName(DispatcherServletAutoConfiguration.DEFAULT_DISPATCHER_SERVLET_BEAN_NAME);
|
||||
return registration;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user