Repository navigation
Treat Kotlin nullable as non-required - #1060
rocketraman wants to merge 2 commits into
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. |
There was a problem hiding this comment.
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
isOptionalis used, also check forisKotlinNullablei.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