[BUG] ObjectMapperHolder destroys Spring autoconfiguration-pattern
See original GitHub issueDescribe the bug Using Spring-Boot you get some Utility-Beans configured automatically depending on the Libraries in your classpath. For Example the Jackson ObjecMapper class ist configured using properties and dependencies from the classpath and published in the Spring-ApplicationContext to be used by every component of the Spring Application.
Azure-messaging for Spring breaks this Pattern by using the com.azure.spring.messaging.implementation.converter.ObjectMapperHolder
Exception or Stack Trace This Antipattern leads to:
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Java 8 date/time type `java.time.LocalDateTime` not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling (through reference chain: de.bertelsmann.ols.old.model.partner.DmdParPartner["accedeDate"])
for Example
To Reproduce Steps to reproduce the behavior: Customize your Jackson-Framework like described in the Spring-Reference Documentation and you will see that this Customisations are noch used by the Azure-Messaging System.
Expected behavior A Library with the Name “spring-messaging-azure” should integrate with teh Spring-Framework and spacially use Spring Configuration-Options.
Setup (please complete the following information): Pom.xml with:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.1</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<java.version>11</java.version>
<spring-cloud.version>2021.0.3</spring-cloud.version>
<jackson.datatype.jsr310.version>2.13.3</jackson.datatype.jsr310.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.azure.spring</groupId>
<artifactId>spring-cloud-azure-dependencies</artifactId>
<version>4.3.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>${jackson.datatype.jsr310.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
Issue Analytics
- State:
- Created a year ago
- Comments:8 (5 by maintainers)
Top GitHub Comments
When i use Spring-Boot i expect that librarys for Spring-Boot use the ObjectMapper from the ApplicationContext or they create a specific ObjectMapper-Bean in the ApplicationContext. I think the Design-Flaw and what Fix is expexted was described in my first Post.
Spring Boot uses the default ObjectMapper created by JacksonAutoConfiguration, which will be managed by IoC. So we can use the default ObjectMapper to replace the one created by ObjectMapperHolder. And I think AWS also uses this way to get an ObjectMapper in S3AutoConfiguration.