Skip to content

Revise and simplify ObjectMapper and MappingJackson2HttpMessageConverter configuration #3891

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wilkinsona opened this issue Sep 3, 2015 · 2 comments
Assignees
Labels
type: blocker An issue that is blocking us from releasing
Milestone

Comments

@wilkinsona
Copy link
Member

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)
@wilkinsona
Copy link
Member Author

The two MappingJackson2HttpMessageConverters is due to a design decision in HttpMessageConverters. It deliberately retains any default converters that duplicate the Spring Boot-specific converters, but positions the default later in the list. I don't intend to address this as part of this issue.

@wilkinsona
Copy link
Member Author

I forgot to update the documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: blocker An issue that is blocking us from releasing
Projects
None yet
Development

No branches or pull requests

1 participant