Spring boot version:"2.2.4.RELEASE" kotlinCoroutineVersion = "1.3.3"

The following config results in a kotlin reflection exception if I run it from as a spring boot test, but works perfectly if I start it as a normal spring app:

@Configuration
class AConfig {
    @Bean
    fun channelString() = Channel<String>()

    @Bean
    fun thread(stringChannel: SendChannel<String>): String {
        thread {
            runBlocking {
                for (i in 1..100) {
                    stringChannel.send("$i")
                }
            }
        }
        return ""
    }

    @Bean
    fun receiver(stringChannel: ReceiveChannel<String>): String {
        runBlocking {

            for (s in stringChannel) {
                println(s)
            }
        }

        return ""
    }
}

Caused by: kotlin.reflect.jvm.internal.KotlinReflectionInternalError: Inconsistent number of parameters in the descriptor and Java reflection object: 2 != 1 Calling: public final suspend fun receiveOrClosed(): kotlinx.coroutines.channels.ValueOrClosed defined in kotlinx.coroutines.channels.AbstractChannel[DeserializedSimpleFunctionDescriptor@70416d07] Parameter types: [class kotlinx.coroutines.channels.AbstractChannel, kotlin.coroutines.Continuation<? super kotlinx.coroutines.channels.ValueOrClosed<? extends E>>]) Default: false

Comment From: maczikasz

I think the problem is somewhere around the MockitoPostProcessors specifically the SpyPostProcessor

Comment From: wilkinsona

@maczikasz Thanks for the report. To help us to investigate, can you please turn the snippet above into a small sample project that we can import into IntelliJ? A zip attached to this issue or a separate repository on GitHub would be ideal.

Comment From: maczikasz

spring-config-channel.zip @wilkinsona sure here you go

Comment From: maczikasz

The issue is not in spring but kotlin will raise a ticket to JetBrains

Comment From: maczikasz

https://youtrack.jetbrains.com/issue/KT-36293