@@ -41,6 +41,7 @@ public class MethodInvocation implements IMethodInvocation {
4141 private final MethodInfo method ;
4242 private Object [] arguments ;
4343 private final Iterator <IMethodInterceptor > interceptors ;
44+ private IMethodInterceptor nextInterceptor ;
4445
4546 private final StoreProvider storeProvider ;
4647
@@ -59,6 +60,19 @@ public MethodInvocation(FeatureInfo feature, IterationInfo iteration, StoreProvi
5960 : CollectionUtil .concat (scopedInterceptors , method .getInterceptors ()).iterator ();
6061 }
6162
63+ private MethodInvocation (FeatureInfo feature , IterationInfo iteration , StoreProvider storeProvider , Object sharedInstance ,
64+ Object instance , Object target , MethodInfo method , Iterator <IMethodInterceptor > interceptors , Object [] arguments ) {
65+ this .feature = feature ;
66+ this .iteration = iteration ;
67+ this .storeProvider = storeProvider ;
68+ this .sharedInstance = sharedInstance ;
69+ this .instance = instance ;
70+ this .target = target ;
71+ this .method = method ;
72+ this .interceptors = interceptors ;
73+ this .arguments = arguments ;
74+ }
75+
6276 @ Override
6377 public SpecInfo getSpec () {
6478 return method .getParent ();
@@ -118,8 +132,12 @@ public void resolveArgument(int index, Object value) {
118132
119133 @ Override
120134 public void proceed () throws Throwable {
121- if (interceptors .hasNext ())
122- interceptors .next ().intercept (this );
135+ if ((nextInterceptor == null ) && interceptors .hasNext ()) {
136+ nextInterceptor = interceptors .next ();
137+ }
138+ if (nextInterceptor != null )
139+ nextInterceptor .intercept (new MethodInvocation (feature , iteration , storeProvider ,
140+ sharedInstance , instance , target , method , interceptors , arguments .clone ()));
123141 else method .invoke (target , arguments );
124142 }
125143}
0 commit comments