1

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
Lezenford
  • 41
  • 1
  • 2
  • 7
  • Does this answer your question? ['this@ActivityName' is not captured error Android/Kotlin](https://stackoverflow.com/questions/67873951/thisactivityname-is-not-captured-error-android-kotlin) – Karsten Gabriel Mar 26 '22 at 20:21
  • no. restart\invalidate doesn't fix it. New project has same problem. You can try to repeat problem - all code in the post – Lezenford Mar 26 '22 at 23:30
  • What is the version of Kotlin? Similar to https://youtrack.jetbrains.com/issue/KTIJ-13877, but this has been fixed. – Konstantin Annikov Mar 28 '22 at 07:33
  • If updating Kotlin to the latest version does not help, please upload a sample project to https://youtrack.jetbrains.com/newIssue?project=KTIJ – Konstantin Annikov Mar 28 '22 at 07:34
  • @KonstantinAnnikov testing on 2 different computers with 2 different kotlin plugin versions. One of that is latest. – Lezenford Mar 28 '22 at 08:52

0 Answers0