Add support for @RequestMapping on Kotlin property accessors
This commit refines InvocableHandlerMethod (both Servlet and Reactive variants) in order to support annotated property accessors as they translate into regular Java methods, instead of throwing a NullPointerException. Closes gh-31856
This commit is contained in:
@@ -98,6 +98,12 @@ class InvocableHandlerMethodKotlinTests {
|
||||
Assertions.assertThat(value).isEqualTo(3.1)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun propertyAccessor() {
|
||||
val value = getInvocable(PropertyAccessorHandler::class.java).invokeForRequest(request, null)
|
||||
Assertions.assertThat(value).isEqualTo("foo")
|
||||
}
|
||||
|
||||
private fun getInvocable(clazz: Class<*>, vararg argTypes: Class<*>): InvocableHandlerMethod {
|
||||
val method = ResolvableMethod.on(clazz).argTypes(*argTypes).resolveMethod()
|
||||
val handlerMethod = InvocableHandlerMethod(clazz.constructors.first().newInstance(), method)
|
||||
@@ -138,6 +144,12 @@ class InvocableHandlerMethodKotlinTests {
|
||||
limit.value
|
||||
}
|
||||
|
||||
private class PropertyAccessorHandler {
|
||||
|
||||
val prop: String
|
||||
get() = "foo"
|
||||
}
|
||||
|
||||
@JvmInline
|
||||
value class LongValueClass(val value: Long)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user