Skip to content
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

Unable to explicitly order WebRequestInterceptors via addInterceptors method [SPR-12673] #17272

Closed
spring-issuemaster opened this issue Jan 29, 2015 · 1 comment

Comments

Projects
None yet
2 participants
@spring-issuemaster
Copy link
Collaborator

commented Jan 29, 2015

Paul opened SPR-12673 and commented

I would like to be able to explicitly order Interceptors via the addInterceptors method on WebMvcConfigurationSupport class.

With the method below the interceptors are run in order they are added to registry.

@Override
protected void addInterceptors(InterceptorRegistry registry) {
    registry.addWebRequestInterceptor(new FirstInterceptor());
    registry.addWebRequestInterceptor(new SecondInterceptor());
    registry.addWebRequestInterceptor(new ThirdInterceptor());
}

Now when I add a path pattern to the first interceptor it becomes a mapped interceptor and then it ends up being run last.

@Override
protected void addInterceptors(InterceptorRegistry registry) {
    registry.addWebRequestInterceptor(new FirstInterceptor()).addPathPatterns("/doh/**");
    registry.addWebRequestInterceptor(new SecondInterceptor());
    registry.addWebRequestInterceptor(new ThirdInterceptor());
}

So in this instance to get the ordering correct I need to add path patterns to all interceptors as follows

@Override
protected void addInterceptors(InterceptorRegistry registry) {
    registry.addWebRequestInterceptor(new FirstInterceptor()).addPathPatterns("/doh/**");
    registry.addWebRequestInterceptor(new SecondInterceptor()).addPathPatterns("/**");
    registry.addWebRequestInterceptor(new ThirdInterceptor()).addPathPatterns("/**");
}

Affects: 4.1.1, 4.1.3, 4.1.4

Referenced from: commits c5d6cc4, c36435c

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented May 19, 2015

Brian Clozel commented

This is now resolved and is available in the latest 4.2.0-BUILD-SNAPSHOT version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.