micronaut-projects / micronaut-serialization

Build Time Serialization APIs for Micronaut
Apache License 2.0
26 stars 19 forks source link

Micronaut 4.3.6 breaks custom serializer for bounded generic types #865

Open SpikeBlues opened 3 months ago

SpikeBlues commented 3 months ago

Expected Behavior

For a bounded generic type (e.g. Point<T extends Serializable>), implementing a custom Serde as depicted in the micronaut-serialization documentation should allow serialization to work properly. This has been the case with Micronaut version up to 4.3.5.

Actual Behaviour

After upgrading to 4.3.6+, we got following error with the same code base:

io.micronaut.serde.exceptions.SerdeException: No serializable introspection present for type Point.
Consider adding Serdeable. Serializable annotate to type Point. 
Alternatively if you are not in control of the project's source code, you can use @SerdeImport(Point.class) to enable serialization of this type.

However, when the generic type is unbounded (e.g. change to Point<T> instead), the test passes.

It seems the behavior has changed since #742 in terms of matching generic argument types.

Steps To Reproduce

Please refer to the reproducer repo with steps: https://github.com/SpikeBlues/micronaut-serde-issue

Environment Information

./gradlew -v

------------------------------------------------------------
Gradle 8.7
------------------------------------------------------------

Build time:   2024-03-22 15:52:46 UTC
Revision:     650af14d7653aa949fce5e886e685efc9cf97c10

Kotlin:       1.9.22
Groovy:       3.0.17
Ant:          Apache Ant(TM) version 1.10.13 compiled on January 4 2023
JVM:          21 (Eclipse Adoptium 21+35-LTS)
OS:           Mac OS X 13.6.7 aarch64

Example Application

https://github.com/SpikeBlues/micronaut-serde-issue

Version

4.3.6

yawkat commented 2 months ago

Needs more eval