'Idea Kotlin Spring webflux + coroutines debug. Evaluate error "this@ is not captured"

Try to create simple application with spring weblux and kotlin coroutines. Like this

@SpringBootApplication
class DemoApplication

fun main(args: Array<String>) {
    runApplication<DemoApplication>(*args)
}

@RestController
class TestController(
    private val testService: TestService
){
    @GetMapping
    suspend fun test() {
        testService.test()
    }
}

@Service
class TestService() {
    private val testMap: Map<Int, String> = mapOf(1 to "1")

    suspend fun test() {
        println("service")
    }
}

If set breakpoint on service fun and try to use evaluate for invoke testMap return error "this@TestService is not captured" enter image description here

How can I correctly use debug for applications like this?

UPD1

Project build.gradle.kts example code:

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
    id("org.springframework.boot") version "2.6.5"
    id("io.spring.dependency-management") version "1.0.11.RELEASE"
    kotlin("jvm") version "1.6.10"
    kotlin("plugin.spring") version "1.6.10"
}

group = "com.example"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_11

repositories {
    mavenCentral()
}

dependencies {
    implementation("org.springframework.boot:spring-boot-starter-webflux")
    implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
    implementation("io.projectreactor.kotlin:reactor-kotlin-extensions")
    implementation("org.jetbrains.kotlin:kotlin-reflect")
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
    testImplementation("org.springframework.boot:spring-boot-starter-test")
    testImplementation("io.projectreactor:reactor-test")
}

tasks.withType<KotlinCompile> {
    kotlinOptions {
        freeCompilerArgs = listOf("-Xjsr305=strict")
        jvmTarget = "11"
    }
}

tasks.withType<Test> {
    useJUnitPlatform()
}

Testing on:

  • Java: 11-17
  • Kotlin plugin: 213-1.6.10-release-961-IJ6777.52


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source