Closed
Description
Affects: 6.0.7
@HttpExchange annotated methods works as expected for simple return types, but not for generic types. For example a function expected to return List, but HttpServiceProxy resolves it as String.
interface SuspendingService {
@GetExchange
suspend fun body(): List<String>
}
Here is a test case :
class HttpServiceMethodKotlinTests {
private val EXPECTED_BODY_TYPE: ParameterizedTypeReference<*> = object : ParameterizedTypeReference<List<String>>() {}
private val client = TestHttpClientAdapter()
private val proxyFactory = HttpServiceProxyFactory.builder(client).build()
@Test
fun suspendingService(): Unit = runBlocking {
val service = proxyFactory.createClient(SuspendingService::class.java)
service.body()
getVerifyClientInvocation("requestToBody", EXPECTED_BODY_TYPE)
}
private fun getVerifyClientInvocation(methodName: String, expectedBodyType: ParameterizedTypeReference<*>) {
assertThat(client.invokedMethodName).isEqualTo(methodName)
assertThat(client.bodyType).isEqualTo(expectedBodyType)
}
private interface SuspendingService {
@GetExchange
suspend fun body(): List<String>
}
}
Result:
expected: ParameterizedTypeReference<java.util.List<? extends java.lang.String>>
but was: ParameterizedTypeReference<class java.lang.String>
When you change function signature as fun body(): Mono<List<String>>
it returns ParameterizedTypeReference<java.util.List<java.lang.String>>
as expected.
As far as i see, Only "suspending methods" affected by it. Flows works as expected.