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

@within not working Spring AOP [SPR-17285] #21818

Closed
spring-projects-issues opened this issue Sep 18, 2018 · 6 comments
Closed

@within not working Spring AOP [SPR-17285] #21818

spring-projects-issues opened this issue Sep 18, 2018 · 6 comments
Labels
in: core status: invalid

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Sep 18, 2018

sahil-ag opened SPR-17285 and commented

@within point-cut doesn't seem to be working when we extend a class and annotate the extended class.
This also doesn't seem to take into account the @inherited annotation

Sample project:
https://github.com/sahil-ag/Spring-AOP-Sample

Project works when we use @target but should also be working for @within


No further details from SPR-17285

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Dec 13, 2018

sahil-ag commented

Hi
Is there any update here?

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Dec 15, 2018

Andy Clement commented

Sorry, haven't had a chance, but I will take a look at the project you attached (thanks for that!) as soon as I can.

@spring-projects-issues spring-projects-issues added type: bug status: waiting-for-triage in: core and removed type: bug labels Jan 11, 2019
@aclement
Copy link
Contributor

@aclement aclement commented Jan 15, 2019

Ok, @within, like within, is about lexical scope and what is declared at compile/weave time. @target, like target, is about dynamic scope and what is happening at runtime.

For the 3 testcases:
If the pointcuts are
( A ): @within(SampleAnnotation) || @annotation(SampleAnnotation)
( B ): @target(SampleAnnotation) || @annotation(SampleAnnotation)

  • testAnnotedMethod - Both A and B match because @annotation(SampleAnnotation) matches on the method in BaseMethod class.
  • testAnnotatedBeanExtended - B matches, A does not match. The method getTestName() is declared in BaseClass and neither that method or that type is annotated, so if that is the static state 'as declared' and so neither of these pointcut components are true in A. Now B matches dynamically because the runtime type on which the getTestName() is being called is a BaseClassExtended which is annotated.
  • testAnnotatedBean - Neither A nor B match. BaseClass nor getTestName() are annotated.

So I am saying it is working as designed. Does that help?

@sahil-ag
Copy link

@sahil-ag sahil-ag commented Mar 8, 2019

Correct me if I am wrong but shouldn't @within consider all the functions which are available to the class at compile time and based on how inheritance works, that function will hence be available in the lexical scope?

@hurelhuyag
Copy link

@hurelhuyag hurelhuyag commented Feb 19, 2020

@annotation not working. I tried whole day to make it work. Is anyone has workaround it?

@sbrannen
Copy link
Member

@sbrannen sbrannen commented Feb 19, 2020

@annotation not working. I tried whole day to make it work. Is anyone has workaround it?

Thanks for getting in touch, but it feels like this is a question that would be better suited to Stack Overflow. As mentioned in the guidelines for contributing, we prefer to use the issue tracker only for bugs and enhancements. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add some more details if you feel this is a genuine bug.

@sbrannen sbrannen added status: invalid and removed status: waiting-for-triage labels Feb 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core status: invalid
Projects
None yet
Development

No branches or pull requests

5 participants