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
Spring MVC: Unexpected bytes added to the HTTP response for kotlin.Unit return type in controller methods #31648
Comments
It should be fixed at framework not boot side, I've created #31647 to handle this. |
@estigma88 You can add |
@quaff Thanks for the suggestion, but does that work with virtual threads? We are using virtual threads heavily in the project |
I'm not expert of kotlin, but I don't think it will conflict with virtual threads. |
This commit fix a regression introduced by spring-projectsgh-21139 via the usage of Kotlin reflection to invoke HTTP handler methods. It ensures that kotlin.Unit is treated as void by returning null. It also polish CoroutinesUtils to have a consistent handling with the regular case, and add related tests to prevent future regressions. Closes spring-projectsgh-31648
This commit fixes a regression introduced by spring-projectsgh-21139 via the usage of Kotlin reflection to invoke HTTP handler methods. It ensures that kotlin.Unit is treated as void by returning null. It also polish CoroutinesUtils to have a consistent handling compared to the regular case, and add related tests to prevent future regressions. Closes spring-projectsgh-31648
Thanks for catching this regression, this should now be fixed. |
I confirm it is working with Spring Boot 3.2.0 |
Affects: Spring Boot 3.2.0-RC2, Spring Web 3.2.0-RC2, Kotlin 1.9.20
Issue
Using a Controller, with return type
kotlin.Unit
, which uses directlyHttpServletResponse
to write the response, adds unexpected bytes to the response. The following is a controller example where a file is read and written to the output directly:The following shows the bytes expected vs current:
123 and 125 bytes are
{
and}
How to reproduce the issue
This is a Spring Boot project with a test that reproduces the issue.
Debugging
My guess would be: there is a new converter which is taking
kotlin.Unit
and tries to serialize it, outputting{
and}
.The text was updated successfully, but these errors were encountered: