Affects: 6.1.7, 6.1.8
We experience AspectJ aspects to be executed twice since updating to Spring-Boot 3.2.6 with Spring-Framework 6.1.8.
The @Aspect
classes are used with AspectJ-CTW via aspectj-maven-plugin
and we initialize them as spring bean with @Bean
configuration.
Now they are automatically falsely initialized as Spring-AOP cglib proxy additionally to the already existing bean.
This means that calls are going first through the proxy-aspect and then through the CTW-aspect.
We also use Spring-AOP proxies for other aspects in the same project, so we can't just completely disable the AOP autoconfig.
This seems to be caused by https://github.com/spring-projects/spring-framework/issues/32793
Comment From: jhoeller
Frankly, we did not expect such mixed AspectJ usage, at least not with the aspect exposed as a bean in the application context. I can see your scenario though. We'll try to make it work without breaking the original Micrometer use case - which is not trivial since AspectJ is trying to blur the lines between the different aspect types, suggesting ajc
compilation for reusable aspect classes that can serve for CTW/LTW as well as for Spring AOP. Maybe we just make autodetection in the context more restrictive while still accepting any kind of AspectJ aspect when explicitly passed into a ProxyFactory
.
Comment From: jhoeller
It looks like we can simply skip target classes that have been compiled with ajc
for aspects that have also been compiled with ajc
- since in that case, the AspectJ compiler has clearly weaved the target class already. I'll roll that into 6.1.9 / 6.0.22 / 5.3.37.
Comment From: jhoeller
This should be fixed in the upcoming 6.1.9 snapshot now. Please give it an early try, I hope it addresses your scenario as expected!
Comment From: MnlK
I built some of the failing projects with 6.1.9-SNAPSHOT and it looks all good again. Thank you!
Comment From: jhoeller
Great to hear, thanks for the feedback!