You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
io.micrometer.core.aop.TimedAspect is annotated with @nonNullApi, however its public Object timedMethod(ProceedingJoinPoint pjp) throws Throwable returns null objects when the wrapped function does so ( or returns void ).
Environment
micrometer-core:1.3.0
To Reproduce
When using this class from Kotlin, the compiler expects that a non-null object is returned and fails at runtime when a null is returned.
Or, changing POV, it is impossible to override the function and return Kotlin's nullable object Any? as the compiler treat the signature as non-nullable.
Expected behavior
The returned value shall be annotated as @Nullable as it is null in some circumstances.
Additional context
This issue is still present on your main branch as of today (
This sounds like something we can and should fix, but I'm curious, why would you be calling that method directly in your code? Or is this a problem even when not directly calling the method in your code?
I wanted to time the execution time of Monos ( form project reactor a.k.a. RxJava ).
Monos are assembled when the timed method is called, but executed later. Therefore, my solution was to override the method timedMethod and inspect the returned type of the wrapped method.
When the timed method is returning a Mono, return a Mono.fromCallable { setupTimers... }.then(pjp.preceed() as Mono<?>).doFinally { finishTimers } ( there are still cases to cover, like cancellation, but this works for the moment being ).
I was able to do so in Java, but not in Kotlin, due to the reported issue.
Describe the bug
io.micrometer.core.aop.TimedAspect is annotated with
@nonNullApi
, however itspublic Object timedMethod(ProceedingJoinPoint pjp) throws Throwable
returns null objects when the wrapped function does so ( or returnsvoid
).Environment
micrometer-core:1.3.0
To Reproduce
When using this class from Kotlin, the compiler expects that a non-null object is returned and fails at runtime when a null is returned.
Or, changing POV, it is impossible to override the function and return Kotlin's nullable object
Any?
as the compiler treat the signature as non-nullable.Expected behavior
The returned value shall be annotated as
@Nullable
as it is null in some circumstances.Additional context
This issue is still present on your main branch as of today (
micrometer/micrometer-core/src/main/java/io/micrometer/core/aop/TimedAspect.java
Line 154 in 259923c
The text was updated successfully, but these errors were encountered: