Conversation
Signed-off-by: ruthes00 <ruthes00@gmail.com>
In Spring Framework 7, MappingJacksonValue is deprecated and no longer supported by the Jackson 3 (tools.jackson) message converters. When a @RepositoryRestController method returns a MappingJacksonValue, the HAL converters receive the wrapper object rather than the inner RepresentationModel, causing _links to be omitted from the response. Introduce MappingJacksonValueResponseBodyAdvice, a ResponseBodyAdvice that intercepts MappingJacksonValue return values before they reach the message converter. The advice: - Unwraps the inner value so the HAL converter serializes it correctly - Propagates any serializationView as a Jackson 3 converter hint - Logs a warning when a Jackson 2 FilterProvider is detected (it cannot be bridged to Jackson 3's tools.jackson.databind.ser.FilterProvider) The advice is registered first in the repositoryExporterHandlerAdapter response body advice chain so it runs before HalFormsAdaptingResponseBodyAdvice. Closes spring-projects#1544 Signed-off-by: ruthes00 <ruthes00@gmail.com>
ruthst00
force-pushed
the
issue/1544
branch
from
September 13, 2026 17:51
a5b34cd to
66431e0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1544
Root cause: In Spring Framework 7,
MappingJacksonValueis deprecated and marked for removal. The Jackson 3 (tools.jackson) message converters (AbstractJacksonHttpMessageConverter) explicitly throwUnsupportedOperationExceptionwhen they receive aMappingJacksonValuebody, and instead use a hints map (Map<String, Object>) keyed by class name. When a@RepositoryRestControllermethod returns aMappingJacksonValuewrapping aRepresentationModel, the HAL converter never sees the inner model — causing_linksto be absent from the response.Fix: Introduced
MappingJacksonValueResponseBodyAdvice— aResponseBodyAdvicethat:beforeBodyWrite()— detectsMappingJacksonValuereturn values, unwraps the inner value (theRepresentationModel), and stashes anyserializationVieworFilterProviderhints in aThreadLocaldetermineWriteHints()— a new Spring 7ResponseBodyAdvicehook that returns the stashed hints as aMap<String, Object>for the Jackson 3 converter to consume, then clears theThreadLocalThe advice is registered first in
RepositoryRestMvcConfiguration.repositoryExporterHandlerAdapter()so it runs beforeHalFormsAdaptingResponseBodyAdvice. A warning is logged when a Jackson 2FilterProvideris detected (it cannot be bridged to Jackson 3's incompatibletools.jackson.databind.ser.FilterProviderAPI). All 8 unit tests pass.