Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AspectJ CTW aspects executed twice #32970

Closed
MnlK opened this issue Jun 6, 2024 · 5 comments
Closed

AspectJ CTW aspects executed twice #32970

MnlK opened this issue Jun 6, 2024 · 5 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: regression A bug that is also a regression
Milestone

Comments

@MnlK
Copy link

MnlK commented Jun 6, 2024

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 #32793

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jun 6, 2024
@jhoeller jhoeller added type: regression A bug that is also a regression in: core Issues in core modules (aop, beans, core, context, expression) and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jun 6, 2024
@jhoeller jhoeller self-assigned this Jun 6, 2024
@jhoeller jhoeller added this to the 6.1.9 milestone Jun 6, 2024
@jhoeller
Copy link
Contributor

jhoeller commented Jun 6, 2024

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.

@jhoeller
Copy link
Contributor

jhoeller commented Jun 6, 2024

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.

@jhoeller
Copy link
Contributor

jhoeller commented Jun 6, 2024

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!

jhoeller added a commit that referenced this issue Jun 6, 2024
Includes defensive ignoring of incompatible aspect types.

Closes gh-32970

(cherry picked from commit 0ea96b4)
jhoeller added a commit that referenced this issue Jun 6, 2024
Includes defensive ignoring of incompatible aspect types.

Closes gh-32970

(cherry picked from commit 0ea96b4)
@MnlK
Copy link
Author

MnlK commented Jun 10, 2024

I built some of the failing projects with 6.1.9-SNAPSHOT and it looks all good again. Thank you!

@jhoeller
Copy link
Contributor

Great to hear, thanks for the feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: regression A bug that is also a regression
Projects
None yet
Development

No branches or pull requests

3 participants