borinquenkid commented on PR #16414:
URL: https://github.com/apache/grails-core/pull/16414#issuecomment-5882521563
Proposal for the custom-serializer gap above: don't sandbox it, remove the
reason it exists. Go fully through Spring Boot's own Jackson customization
model instead of the hybrid "ask Jackson if it owns this type" approach, and
\`registerObjectMarshaller\`/\`rendersValue()\`'s private-API dependency both
disappear at the root.
Verified against the real \`spring-boot-jackson-4.1.1\` sources (Boot 4
split this out of \`spring-boot-autoconfigure\`). \`JacksonAutoConfiguration\`
already does this:
```java
@Bean
StandardJsonMapperBuilderCustomizer standardJsonMapperBuilderCustomizer(
ObjectProvider<JacksonModule> modules, AutowireCapableBeanFactory
beanFactory) {
return new StandardJsonMapperBuilderCustomizer(this.jacksonProperties,
modules.stream().toList(), beanFactory);
}
```
Any \`@Bean JacksonModule\` in the app context is auto-collected and folded
into the one \`JsonMapper\` Boot builds. Three standard, already-documented
ways an app registers a custom marshaller once
\`ConvertersConfigurationInitializer\` is consuming that same mapper (which it
already does, via \`getBeanProvider(JsonMapper.class).getIfUnique()\`):
1. \`@Bean JacksonModule myModule()\` — a \`SimpleModule\` with
\`addSerializer(MyType.class, ...)\`.
2. \`@JacksonComponent\`
(\`org.springframework.boot.jackson.JacksonComponent\`) — Boot's own
convenience annotation; \`JacksonComponentModule\` wires it in.
3. A \`JsonMapperBuilderCustomizer\` bean for lower-level control.
If \`grails.converters.JSON\` fully delegated instead of asking "does
Jackson recognize this type," an app's custom marshaller becomes a plain
\`@Bean JacksonModule\` or \`@JacksonComponent\` — no Grails API, and it
composes correctly with everything else because there's exactly one
serialization mechanism instead of two that have to interoperate. That removes
the nested-custom-serializer bypass from above (nothing left to bypass) and the
\`_serializationContext()\` dependency (no "does Jackson own this" question to
answer — it owns everything).
The part that doesn't fall out for free: \`DomainClassMarshaller\` —
proxies, circular references, \`includes\`/\`excludes\`, \`deep\` associations.
No Jackson equivalent exists for that today. Going fully Spring Boot means it
has to become a \`JacksonModule\` Grails ships (GORM-aware serializers
registered the same way), not stay a separate \`ObjectMarshaller<JSON>\` SPI
bolted on the side. That's a bigger scope than this PR currently takes on, but
it's the architecturally coherent version of the same goal, and 9.0.x is the
right place to make that call rather than carry the hybrid forward.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]