Fixed Circular Bean References in Java Config
Fixes gh-4489
This commit is contained in:
parent
01579be7d4
commit
efc3cadd43
|
@ -160,7 +160,7 @@ public class WebSecurityConfiguration implements ImportAware, BeanClassLoaderAwa
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public AutowiredWebSecurityConfigurersIgnoreParents autowiredWebSecurityConfigurersIgnoreParents(
|
public static AutowiredWebSecurityConfigurersIgnoreParents autowiredWebSecurityConfigurersIgnoreParents(
|
||||||
ConfigurableListableBeanFactory beanFactory) {
|
ConfigurableListableBeanFactory beanFactory) {
|
||||||
return new AutowiredWebSecurityConfigurersIgnoreParents(beanFactory);
|
return new AutowiredWebSecurityConfigurersIgnoreParents(beanFactory);
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,7 @@ import org.springframework.web.context.support.AnnotationConfigWebApplicationCon
|
||||||
* @author Rob Winch
|
* @author Rob Winch
|
||||||
*/
|
*/
|
||||||
abstract class BaseSpringSpec extends Specification {
|
abstract class BaseSpringSpec extends Specification {
|
||||||
|
boolean allowCircularReferences = false
|
||||||
@AutoCleanup
|
@AutoCleanup
|
||||||
ConfigurableApplicationContext context
|
ConfigurableApplicationContext context
|
||||||
@AutoCleanup
|
@AutoCleanup
|
||||||
|
@ -89,6 +90,7 @@ abstract class BaseSpringSpec extends Specification {
|
||||||
|
|
||||||
def loadConfig(Class<?>... configs) {
|
def loadConfig(Class<?>... configs) {
|
||||||
context = new AnnotationConfigWebApplicationContext()
|
context = new AnnotationConfigWebApplicationContext()
|
||||||
|
context.setAllowCircularReferences(allowCircularReferences)
|
||||||
context.register(configs)
|
context.register(configs)
|
||||||
context.setServletContext(new MockServletContext())
|
context.setServletContext(new MockServletContext())
|
||||||
context.refresh()
|
context.refresh()
|
||||||
|
|
|
@ -176,7 +176,7 @@ class WebSecurityConfigurerAdapterTests extends BaseSpringSpec {
|
||||||
static ContentNegotiationStrategy CNS
|
static ContentNegotiationStrategy CNS
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public ContentNegotiationStrategy cns() {
|
public static ContentNegotiationStrategy cns() {
|
||||||
return CNS
|
return CNS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -193,6 +193,7 @@ class WebSecurityConfigurerAdapterTests extends BaseSpringSpec {
|
||||||
|
|
||||||
def "UserDetailsService lazy"() {
|
def "UserDetailsService lazy"() {
|
||||||
setup:
|
setup:
|
||||||
|
allowCircularReferences = true
|
||||||
loadConfig(RequiresUserDetailsServiceConfig,UserDetailsServiceConfig)
|
loadConfig(RequiresUserDetailsServiceConfig,UserDetailsServiceConfig)
|
||||||
when:
|
when:
|
||||||
findFilter(MyFilter).userDetailsService.loadUserByUsername("user")
|
findFilter(MyFilter).userDetailsService.loadUserByUsername("user")
|
||||||
|
@ -274,7 +275,7 @@ class WebSecurityConfigurerAdapterTests extends BaseSpringSpec {
|
||||||
static AuthenticationTrustResolver TR
|
static AuthenticationTrustResolver TR
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public AuthenticationTrustResolver tr() {
|
public static AuthenticationTrustResolver tr() {
|
||||||
return TR
|
return TR
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,7 +155,7 @@ class ExceptionHandlingConfigurerTests extends BaseSpringSpec {
|
||||||
static ContentNegotiationStrategy CNS
|
static ContentNegotiationStrategy CNS
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public ContentNegotiationStrategy cns() {
|
public static ContentNegotiationStrategy cns() {
|
||||||
return CNS
|
return CNS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue