-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Spring Web 6.0.0-M6 breaks Kotlin support for (De-)Serialization in some edge-cases #29192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Could you please share a failing test case? |
Sure. I've uploaded a minimalistic example to github: https://github.com/Evenprime/springtestcase It contains only of an empty application and a test case that calls the actuator health endpoint. This results in the following exception stacktrace:
The same can be observed when starting the application and querying the endpoint /actuator/health directly:
Downgrading to Spring Boot version 3.0.0-M4 (and therefore Spring Web 6.0.0-M5) fixes the issue, the endpoint properly returns Status 200 "UP" instead of throwing an exception and returning Status 500. |
Affects:
Spring Web 6.0.0-M6
Kotlin 1.7.10
Caused by #29068
(De-)Serialization behaviour changed (probably unintentionally when going ) due to a change in how serializer is looked up by spring web framwork, if Kotlin is used. The relevant change happened fixing issue mentioned above. Worked fine in Spring Web 6.0.0-M5 .
Contrary to what the new method name might imply, the call
SerializersKt.serializerOrNull(type);
does NOT always return null if no valid serializer is found, but might also throw an IllegalArgumentExcepton if thetype
variable is not an instance of a certain predefined type:throw IllegalArgumentException("typeToken should be an instance of Class<?>, GenericArray, ParametrizedType or WildcardType, but actual type is $it ${it::class}")
Previously, spring used the
SerializersKt.serializer(...)
method and caught all exceptions. Now it no longer catches exceptions at the places whereSerializersKt.serializerOrNull(type);
is used.Spring doesn't ensure that
type
is any of these instances before callingSerializersKt.serializerOrNull(type);
, therefore this exception will get thrown and not caught (I noticed it in one of my projects when calling the HealthCheck actuator endpoint).Potential fixes would be to roll back the above change, or still have a try/catch block, but potentially narrowed down to only cover the
SerializersKt.serializerOrNull(type);
calls instead.The text was updated successfully, but these errors were encountered: