Skip to content

Webflux coroutine controller responds with "COROUTINE_SUSPENDED" string #45

@sgornostal

Description

@sgornostal

Build:

...
plugins {
	id("org.springframework.boot") version "2.1.5.RELEASE"
	id("io.spring.dependency-management") version "1.0.7.RELEASE"
	kotlin("jvm") version "1.3.31"
	kotlin("plugin.spring") version "1.3.31"
}
...
dependencies {
	implementation("org.springframework.boot:spring-boot-starter-data-mongodb-reactive")
	implementation("org.springframework.boot:spring-boot-starter-webflux")
	implementation("org.springframework.kotlin:spring-webflux-kotlin-coroutine:0.3.7")
	implementation("org.springframework.kotlin:spring-data-mongodb-kotlin-coroutine:0.3.7")
	implementation("org.springframework.kotlin:spring-boot-autoconfigure-kotlin-coroutine:0.3.7")
	implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
	implementation("org.jetbrains.kotlin:kotlin-reflect")
	implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
	implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0-M1")
	implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor:1.3.0-M1")
}
...

Application configuration:

@Configuration
@EnableCoroutine
@EnableCoroutineMongoRepositories
class ApplicationConfiguration

Controller:

@Document(collection = "person")
data class Person(@Id val id: String? = null, val name: String)

interface PersonRepository : CoroutineMongoRepository<Person, String>

data class PersonForm(val name: String)

@RestController
@RequestMapping("/persons")
class PersonController(private val personRepository: PersonRepository) {

    @GetMapping
    suspend fun find(): List<Person> = personRepository.findAll()

    @PostMapping
    suspend fun create(@RequestBody form: PersonForm): Person = personRepository.save(Person(name = form.name))

}

When I send either GET or POST request, server responds with "COROUTINE_SUSPENDED":

GET http://localhost:8080/persons

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 21
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1 ; mode=block
Referrer-Policy: no-referrer

"COROUTINE_SUSPENDED"

Response code: 200 (OK); Time: 9ms; Content length: 21 bytes

It looks like a problem with webflux coroutine because data are stored to database.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions