Conversation
ruthst00
force-pushed
the
issue/1726
branch
from
September 13, 2026 18:47
d11e720 to
2d081a2
Compare
Signed-off-by: ruthes00 <ruthes00@gmail.com>
…ation Entities that extend RepresentationModel carry a private 'links' field backed by an unmodifiable list. When a HAL client echoes back the '_links' object in a PUT or POST body, Jackson attempts to set that field via reflection and throws UnsupportedOperationException. Fix: before handing the ObjectNode to Jackson for intermediate deserialization (PUT path in DomainObjectReader.readPut) or for direct deserialization (POST path in PersistentEntityResourceHandlerMethodArgumentResolver), strip any JSON fields that are not known to Jackson for the target type. 'Known to Jackson' means the field is either: - a mapped persistent property (fieldNameToProperty), - an unmapped Jackson property (e.g. @transient fields that Jackson can still deserialize), or - covered by a @JsonAnySetter catch-all. A new MappedJacksonProperties.isKnownJacksonProperty(String) method encapsulates this check. Fields like '_links' that are not in any of these categories are removed from the ObjectNode before Jackson sees it, preventing the UnsupportedOperationException. Fixes: spring-projects#1726 Signed-off-by: Steve Rutherford <ruthes00@example.com> Signed-off-by: ruthes00 <ruthes00@gmail.com>
ruthst00
force-pushed
the
issue/1726
branch
from
September 13, 2026 18:51
2d081a2 to
d1ca50f
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 #1726
Root cause:
DomainObjectReader.readPut()passes the rawObjectNode(including_links) tomapper.readerFor(target.getClass()).readValue(...)for intermediate deserialization. Jackson sees_links, finds the inheritedlinksfield onRepresentationModel, and tries to set it — but it's unmodifiable.Fix (5 files changed, 173 insertions):
MappedJacksonProperties— AddedisKnownJacksonProperty(String name)which returnstrueif a field is a mapped persistent property, an unmapped Jackson property (e.g.@Transientfields), or covered by@JsonAnySetter. Fields like_linksthat are unknown to Jackson returnfalse.DomainObjectReader.readPut()— AddedstripNonWritableFields()that deep-copies theObjectNodeand removes any fields not known to Jackson before the intermediate deserialization step.PersistentEntityResourceHandlerMethodArgumentResolver— Added the same stripping logic for the POST (create) path, plus a newPersistentEntitiesconstructor parameter wired viaRepositoryRestMvcConfiguration.RepositoryRestMvcConfiguration— Passesentitiesto the new constructor.DomainObjectReaderUnitTests— AddedRepresentationModelEntityfixture andreadPutWithLinksFieldDoesNotThrowForRepresentationModelSubclasstest. All 43 tests pass.