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
Treat Kotlin nullable as non-required #1060
Conversation
Notes on submission / pending work:
Otherwise the implementation turned out to be quite simple and concise. |
Thanks for this PR, I only had a quick look but I would be in favor of not creating a new |
1ad77c6
to
8403735
Compare
Done! |
NOTE: Another place we could use this functionality is when |
@sdeleuze Ping. Looks like it needs another rebase, but would appreciate a review. |
/** | ||
* Return whether this method parameter is declared as a Kotlin | ||
* nullable. | ||
* @since 4.4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's target 5.0 for this feature
Sorry for the delay and thanks for your updated PR. I have added comments on the relevant lines of your commit. Could you also rebase that on top of the new master (Spring Framework 5.0) and add some Kotlin unit tests to check that works? Good idea to support that also for |
9038fea
to
8121c7e
Compare
It looks more complicated to do this [1], so I'd prefer to have this pull request reviewed as-is for now, just to keep things as simple as possible. We can add the
I have updated the pull with all of your comments taken into account. Thanks! [1] It looks like a variation of |
8121c7e
to
7560178
Compare
Ping @sdeleuze for review. |
Modify the core MethodParameter class to return the Kotlin nullability of a parameteter (cached for performance). The Kotlin-specific reflection code is within a new KotlinUtils object. Calls to this code are gated by the presence of Kotlin in the classpath, which is checked once at initialization time. Issue: SPR-14165
Where `isOptional` is used, also check for `isKotlinNullable` i.e. values are not considered required if they are Kotlin nullables: - spring-messaging: named value method arguments - spring-web: named value method arguments - spring-webmvc: request parts This means that Kotlin client code no longer has to explicity specify "required=false" for Kotlin nullables -- this information is inferred automatically by the framework. At this time, this introspection does not apply to bean injection -- only to web and messaging method arguments. Issue: SPR-14165
7560178
to
936758c
Compare
Superseeded by #1242 |
Modify the core MethodParameter class to return the Kotlin nullability
of a parameteter (cached for performance).
Where
isOptional
is used, also check forisKotlinNullable
i.e.values are not considered required if they are Kotlin nullables:
This means that Kotlin client code no longer has to explicity specify
"required=false" for Kotlin nullables -- this information is inferred
automatically by the framework.
Issue: SPR-14165