Skip to content

Reactive Mongo with Kotlin suspend functions #3886

Open
@BarracudaX

Description

@BarracudaX

When writing ReactiveMongoRepository/ReactiveCrudRepository with spring-boot-starter-data-mongodb-reactive and declaring suspend find function with non-nullable kotlin return types, the repository returns null when it can't find an entity instead of EmptyResultDataAccessException.

Here is the fun declaration:
suspend fun findSomeEntitiesById(id: Long): SomeEntity

And this test prints null when called with id that does not exists:

@Test internal fun returnsNllReference() { runBlocking { println(repositoryMy.findSomeEntitiesById(123)) } }

If I replace spring-boot-starter-data-mongodb-reactive with spring-boot-starter-data-r2dbc, it throws

org.springframework.dao.EmptyResultDataAccessException: Result must not be null!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions