Skip to content

AOP Alliance with Kotlin: Joinpoint.proceed() on void method leads to IllegalStateException #24028

@eiselems

Description

@eiselems

Spring Boot Version used: 2.2.0

Steps to reproduce

  1. Use kotlin
  2. Implement the MethodInterceptor interface
  3. Auto generate the methods - it generates override fun invoke(invocation: MethodInvocation?): Any
  4. Call invocation.proceed on a method returning null

Analysis so far:

  • Kotlin does not detect the nullability of the interface and the proceed() method correctly.

Suggestion:

  • Add Spring's Nullable annotation since it is based on JSR-305 (javax.annotation) @Nullable to at least the interface. The method also does not get picked up by the compiler (it is indicating Any!) - but that doesn't seem to be an issue.

Fix:
Replace the return type of the implemented interface method with Any? (instead of Any).

Is this my bad or should the interface suggest that there could be a null value?

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions