Repository navigation
Conversation
…rializer ServiceInstance#getPayload uses @JsonTypeInfo(use = Id.CLASS), so Jackson would instantiate any class named in the JSON. JsonInstanceSerializer now sets a PolymorphicTypeValidator that only permits the configured payload class (and its subtypes) for the payload. Nested polymorphic types with a non-Object base type are unaffected. A new constructor allows supplying a custom validator. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
|
@eolivelli this new polymorphic type validator may be a breaking change for some users and they would need to use the new constructor to provide their own polymorphic type validator. |
pjfanning
marked this pull request as draft
October 14, 2026 14:42
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 #1297
ServiceInstance#getPayload()(andOldServiceInstance) is annotated with@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS), soJsonInstanceSerializerwould load any class named in the JSON, relying only on Jackson's built-in gadget deny-list.Changes
JsonInstanceSerializernow sets aPolymorphicTypeValidatoron itsObjectMapper. By default:Objectbase type (i.e. the erased payloadT) must be the configuredpayloadClassor a subtype; anything else fails withInvalidTypeIdException@JsonTypeInfofield inside the user's payload) are allowed as before, so existing payloads with their own typed fields keep workingJsonInstanceSerializer(Class<T>, boolean, PolymorphicTypeValidator)for users who need a different policy.Object.classas the payload class keep the previous (permissive) behaviour; they can use the new constructor to lock it down.Related
Class.forName(name, true, loader), so a class's static initializer runs before the validator can reject it; newer versions load without initializing. This PR should go in alongside chore: Upgrade jackson-version to 2.18.11 #1296.Tests
Id.CLASSfield still round-trips🤖 Generated with Claude Code