Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling Kotlin suspend functions in non-reactive application crashes due to unresolvable class #32599

Closed
molikuner opened this issue Apr 9, 2024 · 0 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) theme: kotlin An issue related to Kotlin support type: regression A bug that is also a regression
Milestone

Comments

@molikuner
Copy link

Affects: 6.1.1+ (Spring Boot 3.2.x)
Reproducer: reproducer.zip


Problem

Calling any suspend function in a service that is proxied by SpringCGLIB might throw an exception due to missing classes in the classpath (java.lang.ClassNotFoundException: org.reactivestreams.Publisher). For some reason this only occurs when another function in the specified class is getting changed too. E.g. if there is an @Transactional method, only then this bug occurs.

Expected Behavior

When calling a suspend function, the call should not be re-written on a non-reactive stack regardeless of other functions in the , similar to how it worked in 6.0.x.

Actual Behavior

When another function in the service forces some new behavior to be introduced by the SpringCGLIB proxy, then the suspend function should be left untouched in a non-reactive application.

Reproducer

reproducer.zip

Crashes with SB 3.2.X, works with SB 3.1.X:

import jakarta.transaction.Transactional
import kotlinx.coroutines.runBlocking
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.stereotype.Service

@SpringBootApplication
class DemoCoroutinesCrashApplication

@Service
class DemoService {

    @Transactional
    fun somethingTransaction() {

    }

    suspend fun mySuspendFunction(): Int {
        return 123
    }
}

@SpringBootTest
class DemoCoroutinesCrashApplicationTests {

    @Autowired
    private lateinit var demoService: DemoService

    @Test
    fun `should not crash`(): Unit = runBlocking {
        demoService.mySuspendFunction()
    }
}
@sdeleuze sdeleuze self-assigned this Apr 9, 2024
@sdeleuze sdeleuze added theme: kotlin An issue related to Kotlin support status: waiting-for-triage An issue we've not yet triaged or decided on type: regression A bug that is also a regression and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Apr 9, 2024
@sdeleuze sdeleuze added this to the 6.1.6 milestone Apr 9, 2024
@jhoeller jhoeller added the in: core Issues in core modules (aop, beans, core, context, expression) label Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) theme: kotlin An issue related to Kotlin support type: regression A bug that is also a regression
Projects
None yet
Development

No branches or pull requests

3 participants