Avoid early initializations

This commit flags the two `BeanPostProcessors` registered by the
embedded support as `synthetic` so that they don't trigger an early
initialization of other components.

Closes gh-8467
This commit is contained in:
Stephane Nicoll
2017-03-03 16:38:58 +01:00
parent dac3810bc1
commit 9fb9a67c4b
3 changed files with 30 additions and 23 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
@@ -58,6 +58,7 @@ import org.springframework.util.ObjectUtils;
* @author Phillip Webb
* @author Dave Syer
* @author Ivan Sopov
* @author Stephane Nicoll
*/
@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE)
@Configuration
@@ -136,17 +137,21 @@ public class EmbeddedServletContainerAutoConfiguration {
if (ObjectUtils.isEmpty(this.beanFactory.getBeanNamesForType(
EmbeddedServletContainerCustomizerBeanPostProcessor.class, true,
false))) {
RootBeanDefinition beanDefinition = new RootBeanDefinition(
EmbeddedServletContainerCustomizerBeanPostProcessor.class);
beanDefinition.setSynthetic(true);
registry.registerBeanDefinition(
"embeddedServletContainerCustomizerBeanPostProcessor",
new RootBeanDefinition(
EmbeddedServletContainerCustomizerBeanPostProcessor.class));
beanDefinition);
}
if (ObjectUtils.isEmpty(this.beanFactory.getBeanNamesForType(
ErrorPageRegistrarBeanPostProcessor.class, true, false))) {
RootBeanDefinition beanDefinition = new RootBeanDefinition(
ErrorPageRegistrarBeanPostProcessor.class);
beanDefinition.setSynthetic(true);
registry.registerBeanDefinition("errorPageRegistrarBeanPostProcessor",
new RootBeanDefinition(
ErrorPageRegistrarBeanPostProcessor.class));
beanDefinition);
}
}