• Andy Wilkinson's avatar
    Allow HttpMsgConverter to depend on ConvService without creating a cycle · e5906a6b
    Andy Wilkinson authored
    In an MVC web application, DelegatingWebMvcConfiguration provides the
    ConversionService while also consuming WebMvcConfigurerAdapters that,
    among other things, can configure HTTP message converters. Boot's
    WebMvcConfigurerAdapter, WebMvcAutoConfigurationAdapter, consumes
    the HttpMessageConverters bean and uses it to configure Spring MVC's
    HTTP message converters. This can create a bean dependency cycle if
    an HTTP message converter bean depends, directly or indirectly on
    the ConversionService. An example of the cycle is:
    
    ┌─────┐
    |  jsonComponentConversionServiceCycle.ThingDeserializer defined in …
    ↑     ↓
    |  org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration
    ↑     ↓
    |  org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter
    ↑     ↓
    |  org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration
    ↑     ↓
    |  mappingJackson2HttpMessageConverter defined in class path resource [org/springframework/boot/autoconfigure/web/JacksonHttpMessageConvertersConfiguration$MappingJackson2HttpMessageConverterConfiguration.class]
    ↑     ↓
    |  jacksonObjectMapper defined in class path resource [org/springframework/boot/autoconfigure/jackson/JacksonAutoConfiguration$JacksonObjectMapperConfiguration.class]
    └─────┘
    
    This commit breaks the cycle by making WebMvcAutoConfigurationAdapter
    consume HttpMessageConverters lazily. This allows the adapter to be
    created without triggered instantiation of every HTTP message
    converter bean and all their dependencies. This allows it to be
    injected into DelegatingWebMvcConfiguration without triggering an
    attempt to retrieve the ConversionService.
    
    Closes gh-9409
    e5906a6b
Name
Last commit
Last update
.github Loading commit data...
.mvn Loading commit data...
eclipse Loading commit data...
spring-boot Loading commit data...
spring-boot-actuator Loading commit data...
spring-boot-actuator-docs Loading commit data...
spring-boot-autoconfigure Loading commit data...
spring-boot-cli Loading commit data...
spring-boot-dependencies Loading commit data...
spring-boot-deployment-tests Loading commit data...
spring-boot-devtools Loading commit data...
spring-boot-docs Loading commit data...
spring-boot-full-build Loading commit data...
spring-boot-integration-tests Loading commit data...
spring-boot-parent Loading commit data...
spring-boot-samples Loading commit data...
spring-boot-starters Loading commit data...
spring-boot-test Loading commit data...
spring-boot-test-autoconfigure Loading commit data...
spring-boot-tools Loading commit data...
.editorconfig Loading commit data...
.gitignore Loading commit data...
.settings-template.xml Loading commit data...
.travis.yml Loading commit data...
CODE_OF_CONDUCT.adoc Loading commit data...
CONTRIBUTING.adoc Loading commit data...
LICENSE.txt Loading commit data...
README.adoc Loading commit data...
mvnw Loading commit data...
mvnw.cmd Loading commit data...
pom.xml Loading commit data...