-
Bug
-
Resolution: Done
-
Major
-
2.2.16.SP1
-
None
Using a Service class like this:
@Interceptors(MyInterceptor.class) public class TestService { ... } @ManagedBean public class MyInterceptor { Object field; @AroundConstruct public void wrapConstructor(InvocationContext ctx) throws Exception { field = new Object(); } @AroundInvoke public Object guard(final InvocationContext context) throws Exception { assert field != null; } }
I would expect the assert to pass. However it fails, because weld creates two instances of this interceptor, one for each Interception Type.
I did not see this documented, and I am not sure if it is a bug. If not, more documentation would help.
JSR 318 seems to say this:
http://download.oracle.com/otndocs/jcp/interceptors-1_2-mrel2-spec/
"Except as noted below, when the target instance is created, a corresponding interceptor instance is created for each associated interceptor class."
"The applicability of a method-level interceptor to more than one method of an associated target class does not affect the relationship between the interceptor instance and the target class—only a single instance of the interceptor class is created per target class instance"
- is related to
-
CDITCK-516 A single interceptor instance should be used if both AroundConstruct and AroundInvoke are declared
- Resolved