spring-data-commons icon indicating copy to clipboard operation
spring-data-commons copied to clipboard

`MethodValidationInterceptor` is added after `ImplementationMethodExecutionInterceptor`

Open riba2101 opened this issue 1 year ago • 6 comments

Hi,

long story short: org.springframework.aop.framework.ReflectiveMethodInvocation.proceed does not go trough the whole chain and after RepositoryFactorySupport.ImplementationMethodExecutionInterceptor the MethodValidationInterceptoris not being called. That being said, MethodValidationInterceptor should be higher up in the chain?

BR

riba2101 avatar Aug 24 '24 12:08 riba2101

If you would like us to spend some time helping you to diagnose the problem, please spend some time describing it and, ideally, providing a minimal yet complete sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.

mp911de avatar Aug 26 '24 07:08 mp911de

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

spring-projects-issues avatar Sep 02 '24 07:09 spring-projects-issues

hi,

sry for the wait, was a bit busy - the repo can be found here: https://github.com/riba2101/spring-data-validaition-demo

riba2101 avatar Sep 02 '24 08:09 riba2101

Spring Data repository invocations are dispatched by ImplementationMethodExecutionInterceptor. However, we still set a target source and therefore, the bean post-processor inserts MethodValidationInterceptor at the end of the advisory chain.

If we do not set the target source in RepositoryFactorySupport, then the bean post-processor inserts MethodValidationInterceptor before ImplementationMethodExecutionInterceptor and so it invokes the validator.

Have you locally tried to change RepositoryFactorySupport to see whether the change would make sense to you?

mp911de avatar Sep 03 '24 07:09 mp911de

oh, to be fair i didnt try it, a nice idea... this would be nice to document and/or make the process easier to integrate? since the MethodValidationInterceptor or rather the AOP validation is a global "feature" in the spring ecosystem, it would make sense to treat it as such?

riba2101 avatar Sep 03 '24 08:09 riba2101

If such a change works for you, then we would apply that one globally so that there's no need for customizations.

mp911de avatar Sep 03 '24 12:09 mp911de