spring-projects / spring-projects/spring-hateoas

Wrong marshalling from ControllerAdvice

Open
#279 6 comments 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Feb 27, 2015.

process: waiting for feedback
Dominant language
Java
Stars
1.1k
Forks
476
PR merge metrics
No merged PRs in 30d

Description

I'm using an exception handler annotated with @ControllerAdvice in a Spring-MVC application. For some errors, I want to return a useful response containing HAL-links.

Unfortunately, those links are not rendered correctly in JSON as "_links", but rather as "links". It seems that when using @ControllerAdvice, the SerializerMixins are not configured for Jackson: Through debugging, I noticed that DefaultSerializerProvider._config.mixInAnnotations is empty here, but contains, among others, "org.springframework.hateoas.hal.ResourceSupportMixin" when marshalling from an ordinary @RestController. The content-type is correctly set to "application/hal+json".

Did I miss something? Is there a way to render correct links?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.