Description
Affects: At least 4.2.1 - 5.3.9, probably all versions.
A !target(class)
pointcut doesn't behave as expected: It seems like the negation implementation is wrong.
From my testing x && !target(org.springframework.web.filter.GenericFilterBean)
behaves like x || target(org.springframework.web.filter.GenericFilterBean)
instead.
I've created an example project https://github.com/F43nd1r/spring-aop-negation-issue-demo. Just try to run the application. You'll see a stacktrace like this:
java.lang.NullPointerException: Cannot invoke "org.apache.commons.logging.Log.isDebugEnabled()" because "this.logger" is null
at org.springframework.web.filter.GenericFilterBean.init(GenericFilterBean.java:241)
That means a bean extending GenericFilterBean must've matched the pointcut and thus was proxied (GenericFilterBean implementations cannot be cglib proxied due to its implementation).
Note: This issue was also described in this stackoverflow post nearly six years ago https://stackoverflow.com/questions/33136530/target-negation-not-working-in-spring-aop.