I recently upgraded Spring Boot from 3.3.0 to 3.4.0 and one of my aspects stopped working.
My custom annotation named @OnError(clazz =...)
is added on method level and has this aspect pointcut targeting it:
@Around("execution(* de.hidden.service.api.controller..*.*(..)) && @annotation(de.hidden.service.api.util.aspects.errorshandling.OnError)")
I am also using the @Timed
annotation from Micrometer related to TimedAspect
. I use this annotation on class level.
With Spring Boot 3.3.0, both aspects were working fine. Since 3.4.0, TimedAspect
stopped working when using the aspect targeting my @OnError
.
1.4.2
.@Order
(very high or very low, has no effect).TimedAspect
, the pointcut seems not to match - it does not stop in the method's first line.It would be great if someone gives a clue.
Update: I added a MCVE here: https://github.com/mzander/spring-boot-3.4.0-aop-MCVE
I used the TimedAspect
and the CountedAspect
from Micrometer. Same problem - only one if them is executed. In this example the TimedAspect
is executed but not the CountedAspect
.
This is too long for a comment, so I am writing a preliminary answer.
I played with your MCVE project and found out that what breaks the behaviour in your case is the switch from dependency io.micrometer:micrometer-core:1.13.9
to 1.14.0
or above. All the other Micrometer dependencies can be 1.14.2
, it still works. The reason why you see it break in Boot 3.4.0 is that your dependency management only considers micrometer-registry-prometheus
, but not the others automatically imported as transitive dependencies. If you manually do something like this, it will continue working in Boot 3.4.0:
implementation("io.micrometer:micrometer-registry-prometheus:1.14.2")
implementation("io.micrometer:micrometer-core:1.13.9")
implementation("io.micrometer:micrometer-observation:1.14.2")
implementation("io.micrometer:micrometer-jakarta9:1.14.2")
implementation("io.micrometer:micrometer-commons:1.14.2")
As soon as you switch to micrometer-core:1.14.0
or higher, timing and counting aspects no longer behave as expected. This might be a side effect of Micrometer issue #1149, which was solved for 1.14.0 and to which I contributed a bit, even though in the end the commit was a bit different from what I had in mind. I have not debugged it in detail, but maybe you want to talk to the Micrometer people. I am not a Micrometer user, just an AOP expert.
Actually, I am not sure what you want to achieve with post-compile weaving and why you think you need it. You did not explain, and your MCVE does not make it clear either. Depending on your answer, maybe you need to configure the Freefair plugin differently, because on the one hand you seem to wish to use Micrometer and your custom aspect as Spring components, on the other hand you seem to think you need native AspectJ for some reason. You need to be careful not to mix them up in a wrong way.