Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
ExposeInvocationInterceptor doesn't make a best effort to be first in execution order [SPR-12351] #16956
ExposeInvocationInterceptor, which is automatically added to the chain when using an AspectJ aspect, should run first, but doesn't make enough efforts to do so. If this does not occur, an exception will be thrown at runtime saying not all parameters could be bound (which may be misleading to the developer, since the number of arguments being match does not coincide with those he set in the advice; and no reference to ExposeInvocationInterceptor is ever made; not even on the official documentation http://docs.spring.io/spring/docs/4.1.x/spring-framework-reference/html/aop.html#aop-ataspectj-advice-ordering )
First of all, it's implementation of
Also of note, is that even setting it to Ordered.HIGHEST_PRECEDENCE would not guarantee it to run first when the other aspect has Ordered.HIGHEST_PRECEDENCE. This could be attoned by using PriorityOrdered instead of Ordered in ExposeInvocationInterceptor. Doing so would guarantee the interceptor runs first to every other aspect, except maybe those that also are PriorityOrdered with Ordered.HIGHEST_PRECEDENCE.
Referenced from: commits fb08644
Juergen Hoeller commented
As of 4.1.2, ExposeInvocationInterceptor declares itself as PriorityOrdered now. An option for another interceptor to override with PriorityOrdered and HIGHEST_PRECEDENCE is still left as an escape hatch; note that no regular interceptor will ever implemented PriorityOrdered, so this should be alright.