Skip to content
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

Replace KotlinBodySpec with proper ResponseSpec extensions #28144

Closed
sdeleuze opened this issue Mar 8, 2022 · 1 comment
Closed

Replace KotlinBodySpec with proper ResponseSpec extensions #28144

sdeleuze opened this issue Mar 8, 2022 · 1 comment
Assignees
Labels
in: test Issues in the test module theme: kotlin An issue related to Kotlin support type: enhancement A general enhancement
Milestone

Comments

@sdeleuze
Copy link
Contributor

sdeleuze commented Mar 8, 2022

Due to #20606, we had to introduce KotlinBodySpec in Spring Framework 5.0.x in order to unlock Kotlin developers for most common use cases of WebTestClient in Kotlin.

As of Kotlin 1.6, the related Kotlin issue on recursive generic types has been fixed, making it possible for Spring Framework to provide regular reified extensions for ResponseSpec methods that takes a ParameterizedTypeReference (to be verified of course, but that's my current understanding).

As a consequence, my proposal is in Spring Framework 6 to remove KotlinBodySpec, as well as the current inline fun <reified B : Any> ResponseSpec.expectBody(): KotlinBodySpec<B> extension, and introduce regular reified extensions for ResponseSpec.expectBody since ResponseSpec.expectBodyList, ResponseSpec.returnResult extensions already exists.

This is a breaking change, I am afraid impossible to avoid, so it should be mentioned in the release notes. I am not sure we should deprecate the related extension in Spring Framework 5.3 since we need to support Kotlin 1.5 there and the current extension prevent to introduce the new proper one describe in this issue.

@sdeleuze sdeleuze added in: test Issues in the test module type: enhancement A general enhancement theme: kotlin An issue related to Kotlin support labels Mar 8, 2022
@sdeleuze sdeleuze added this to the 6.0.0-M3 milestone Mar 8, 2022
@poutsma poutsma changed the title Replace KotlinBodySpec by proper ResponseSpec extensions Replace KotlinBodySpec with proper ResponseSpec extensions Mar 8, 2022
poutsma added a commit to poutsma/spring-framework that referenced this issue Mar 8, 2022
Prior to this commit, the ResponseSpec::expectBody extension function
returned a special KotlinBodySpec, due to
https://youtrack.jetbrains.com/issue/KT-5464.

Now that KT-5464 has been fixed in Kotlin 1.6, we have no need for
KotlinBodySpec, so this commit replaces it with a normal extension
function.

Closes spring-projectsgh-28144
@poutsma poutsma closed this as completed in 1be3eec Mar 8, 2022
@sdeleuze
Copy link
Contributor Author

See related comment in KT-5464 where we discussed the fact that while this is now usable with Kotlin 1.6+, Kotlin is still more verbose than Java so there is room for improvement.

sbrannen added a commit that referenced this issue Nov 21, 2023
Since gh-28144 was resolved in Spring Framework 6.0, these notes are no
longer relevant.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: test Issues in the test module theme: kotlin An issue related to Kotlin support type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants