Skip to content

AbstractTraceInterceptor causes problems when implemented in Kotlin #22435

Closed
@nlochschmidt

Description

@nlochschmidt

The documentation for AbstractTraceInterceptor#invokeUnderTrace states that the return value should be the result of the call to MethodInvocation.proceed() (see AbstractTraceInterceptor.java#L238). The result of invocation.proceed() however can be null, but since the package-info.java in org.springframework.aop.interceptor (see package-info.java#L6) declares the return value of invokeUnderTrace as non-nullable the Kotlin compiler will add a checkExpressionValueIsNotNull before returning the result of invocation.proceed().

This causes a runtime exception that looks like this:

java.lang.IllegalStateException: invocation.proceed() must not be null

I thought I could simply set the return value of the overridden invokeUnderTrace to Any? however that doesn't work since the compiler sees the @NonNullApi and complains with

Error:(18, 76) Kotlin: Return type of 'invokeUnderTrace' is not a subtype of the return type of the overridden member 'protected/*protected and package*/ abstract fun invokeUnderTrace(p0: MethodInvocation, p1: Log): Any defined in org.springframework.aop.interceptor.AbstractMonitoringInterceptor'

Affects: 5.1.4.RELEASE

Metadata

Metadata

Assignees

Labels

status: backportedAn issue that has been backported to maintenance branchestype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions