Rule request: @Advice should be thread safe when used as single instance
The Spring @Advice, used in AOP, creates one instance per default and fields in shared instances should be thread safe like a regular @Component.
As the docs explain: "By default there will be a single instance of each aspect within the application context." (https://docs.spring.io/spring-framework/docs/2.5.x/reference/aop.html#aop-instantiation-models)
Also other instantiation models exits, e.g. for perthis and pertarget:
@Aspect("perthis(com.xyz.myapp.SystemArchitecture.businessService())")
Maybe these should/can be excluded from the rule. Some instantiation strategies also depend on the lifecycle of the object being wrapped, e.g. a request scoped service. (Still you can argue that these aspects should be thread safe if they can be accessed by multiple threads in one request?)
@Aspect()
public class MyAspect {
private int someState; // bad: not thread safe/guarded
@Before(com.xyz.myapp.SystemArchitecture.businessService())
public void recordServiceUsage() {
// ...
}
}
Same case with @Aspect("perthis(com.xyz.myapp.SystemArchitecture.businessService())")?