-
Bug
-
Resolution: Done
-
Major
-
1.1.2.Final
-
None
-
Release Notes
The CDI spec says:
An interceptor instance is a dependent object of the object it inter-cepts.
The Interceptors spec says:
The lifecycle of an interceptor instance is the same as that of the target class instance with which it
is associated. When the target instance is created, a corresponding interceptor instance is created for
each associated interceptor class. These interceptor instances are destroyed when the target instance
is removed.
and also
An interceptor instance may hold state.
It is clear that at most one instance of an interceptor class should be created for an instance of a CDI bean. However, Weld currently creates an instance per method per target instance.
Having a simple intercepted bean:
@ApplicationScoped @LionBinding public class Lion public Object foo() { return null; } public Object bar() { return null; } }
- multiple invocations of a single method (e.g. foo()) are intercepted by the same interceptor instance
- when invoking different methods on the same bean instance, every method is intercepted by a different interceptor instance - which is wrong