-
Notifications
You must be signed in to change notification settings - Fork 556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Duplicate calls of a custom HandlerInterceptor's methods after updating to Spring Data REST 3.4 #1955
Comments
It looks like it's not as simple as adding such a bean to a Boot 2.4.1 application. Any more details on how to reproduce or if you can provide a sample? You can also try debugging in |
Hi, I made a sample project that reproduces the issue. You can find it here https://github.com/lwitzani/springIssue26378 Best regards, |
It seems that on application start in class RepositoryRestMvcConfiguration in method restHandlerMapping() in both branches the result is equal (repositoryMapping has my interceptor in adaptedInterceptors as well as basePathMapping has my my interceptor in adaptedInterceptors). So when doing the post request i noticed that on the branch with the old version This is only done once in the old version. When switching to the new version, this process is done twice for (i think) both of the delegates in the class DelegatingHandlerMapping. The delegates are from my understanding the former mentioned repositoryMapping and basePathMapping (which as mentioned above both have my custom interceptor in their adaptedInterceptors). So this results in adding the custom interceptor twice to the same list. Whole thing is unfortunately more like searching in the dark for me. |
Thanks for the sample. This looks like a possible bug in Spring Data REST. Its |
Just a quick heads up: the issue stems from Spring Data REST's move to let I'll move the ticket to Spring Data REST for a fix. |
We actually do not want to inherit all the functionality implemented in AbstractHandlerMapping. The sole reason we did so before was to override the method to propagate the PathPatternResolver to the downstream HandlerMappings. We now just declare the method on DHM directly. Fixes GH-1955.
This in place. Feel free to give the snapshots a try. |
I just tried it with 3.4.4-SNAPSHOT of branch "3.4.x" and 3.5.0-SNAPSHOT of branch "master" and can confirm that it works in both cases. Thanks for fixing this so quickly. Issue should be resolved with the 3.4.4 release! Nice job! |
I believe (from just now reading the fix) that this is also effecting SimpleUrlHandlerMapping; Noticed this hasn't been added to SimpleUrlHandlerMapping and I am seeing this error:
|
|
will do. Thx. |
Hi,
Background:
We have a Spring Boot project and recently updated our dependencies from Spring Boot 2.3.7.RELEASE to 2.4.0!
Spring Framework therefore changed from 5.2.12.RELEASE to 5.3.1
Use case:
We have a custom interceptor (let's call it ActivityLoggerInterceptor) that implements org.springframework.web.servlet.HandlerInterceptor
We are registering the interceptor similar to the following:
This worked perfectly on Spring Boot 2.3.7.RELEASE / Spring 5.2.12.RELEASE meaning the handler methods preHandle and afterCompletion were called once per request.
The issue:
After updating to Spring Boot 2.4.0 / Spring 5.3.1 the methods preHandle and afterCompletion in our interceptor are each called twice
Observations:
After some debugging i found that our Interceptor is somehow now found twice (see the picture below).
From there it goes deep into Spring ...
Because of this and because i did not find anything that our registration of the Interceptor could be wrong now, i am writing this issue.
Looking through the closed and open issues i did not find anything that would match this problem. But it seems that something around MappedInterceptors has changed in Spring.
Can you help me somehow :)? Thanks so much!
Best regards,
Lukas
The text was updated successfully, but these errors were encountered: