Skip to content

@PreAuthorize in combination with kotlin coroutines and @Transactional does not proceed to invoke TransactionInterceptor #10252

@rolvraen

Description

@rolvraen

Describe the bug

Unsure whether or not this is a bug or expected behaviour. When annotating a suspending kotlin function with both
@PreAuthorize and @Transactional
and not returing a Mono/Flux/Flow the PrePostAdviceReactiveMethodInterceptor does not proceed to invoke the transaction interceptor. It is possible to work around this issue by for example moving the @Transactional annotation to the RestController

To Reproduce

@Service
class Dummy(private val repository: FooRepository) {
    @PreAuthorize("hasAnyAuthority('FOO', 'BAR')")
    @Transactional
    suspend fun foo(name: String): FooDto {
        val rowsUpdated = repository.insertSomethingSuspended()
        return FooDto(name)
    }
    data class FooDto(val name: String)
}

Expected behavior
I would expect the PrePostAdviceReactiveMethodInterceptor to proceed to the next interceptor in the chain

Metadata

Metadata

Assignees

Labels

in: coreAn issue in spring-security-coretype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions