Skip to content

Revise and simplify ObjectMapper and MappingJackson2HttpMessageConverter configuration #3891

Closed
@wilkinsona

Description

@wilkinsona

Some observations:

  • There are two MappingJackson2HttpMessageConverters registered with Spring MVC, both of which have the same supported media types. I don't understand why we need two.
  • If you have Spring Data REST on the classpath, HypermediaAutoConfiguration gets switched off which means that spring.hateoas.apply-to-primary-object-mapper has no effect.
  • If you have Spring Data REST on the classpath, I believe that Spring HATEOAS's ObjectMapper is created before JacksonAutoConfiguration runs. This means that HATEOAS's ObjectMapper becomes the only auto-configured ObjectMapper, but it isn't annotated @Primary.
  • We should try to move away from using Jackson2HalModule and its handler instantiator directly as @olivergierke considers them to be private API.

Some goals:

  • spring.jackson.* properties should take effect irrespective of what's on the classpath.
  • When Spring HATEOAS or Spring Data REST are on the classpath, spring.jackson.* should affect their ObjectMapper(s)
  • When Spring HATEOAS is on the classpath, HAL-formatted responses should be sent in response to requests that accept application/json (HAL not set as default in 1.2.0 #2147)
  • The actuator's JSON output should be affected by spring.jackson.*, irrespective of whether or not Spring HATEOAS and Spring Data REST are on the classpath. (Spring-boot-starter-data-rest prevents JSON pretty print in actuator. #1729)

Metadata

Metadata

Assignees

Labels

type: blockerAn issue that is blocking us from releasing

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions