Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
No way to specify @Pointcut that matches either a method or a class level annotation, binding expression do not short-circuit [SPR-10285] #14919
I have a simple annotation:
which I can apply either on a method or class level (which would then mean it applies to all methods). In my aspect, I have the following pointcut and advice:
and a simple usage class:
This fails at runtime with the following exception:
Why is the binding inconsistent?
So, I tried to replace the advice with the following:
Now, I get a NPE:
The problem is that the binding expression is not short-circuit, i.e., the annotation on the method is found, but spring (or is it aspectj?) binds further and bind a null Tx annotation on the class level to the parameter. This can be easily checked when the PersonService class has both class-level and method-level annotations configured.
I attach a groovy-2.1.0 and gradle-1.4 based project to help easily reproduce this issue. Just invoke
in the project folder. I also configured remote debugging so, but it doesn't suspend the JVM - change line 78 of build.gradle accordingly.