Support Kotlin Context Parameters#35428
Support Kotlin Context Parameters#35428SIMULATAN wants to merge 2 commits intospring-projects:mainfrom
Conversation
Signed-off-by: SIMULATAN <jakob@simulatan.me>
d5a1da2 to
99fa9dd
Compare
|
Could you please add related test(s)? |
Signed-off-by: SIMULATAN <jakob@simulatan.me>
11ed8e7 to
e69b67b
Compare
|
Added tests in a fixup commit, analogous to the existing Kotlin Extension Function tests. Had to force-push once as I messed up the GPG signing on my work device. Let me know in case any further modifications are wanted. |
|
As mention in #35134, I prefer not rushing a support in 7.0, so I have planned merging this PR for 7.1, along with the @SIMULATAN Could you please share a reproducer for an application using this feature? I would like to fully understand the various use cases of Kotlin context parameters with Spring, so that would help to have for example a controller with suspending functions using this feature, in addition to the tests you provided. |
Totally fair. Perhaps more people will see and try out this PR, hopefully providing additional feedback in the process.
I've implemented a simple Todo-like application showcasing our use case: multitenancy. Here's the repo: https://github.com/SIMULATAN/spring-context-parameter-demo |
Note: finding a commit message for this change is quite difficult, the current one is likely to cause confusion. I'd appreciate better suggestions
Originally introduced as Beta in 2.2.0, Context Parameters are a new Kotlin feature that I wanted to use in my project.
Those parameters have a different
KParameter.Kind(CONTEXT) and are therefore not supported by the current CoroutinesUtils implementation. This resulted in the following error message:Status
kotlin-reflect's Context Parameters support was first released in 2.2.20-Beta1. Therefore, I had to target the latest 2.2.20 RC with this PR.Once 2.2.20 is formally released, I'll await the update on Spring's main branch, rebase onto it, and set the PR as ready to merge.With 86fb62c, main is using the latest Kotlin release. I've done the rebase and marked the PR as ready to review. Thanks in advance for your considerations!