Skip to content

Mapped interceptors are not applied to current handler [SPR-7946] #12601

@spring-projects-issues

Description

@spring-projects-issues

Javier Antoniucci opened SPR-7946 and commented

At AbstractUrlHandlerMapping.getHandlerInternal (line 210) a HandlerExecutionChain object called chain is created or casted from handler, then mappedInterceptors are added to the chain but the variable scope ends and chain is not assigned to the handler variable.

if (handler != null && this.mappedInterceptors != null) {
     Set<HandlerInterceptor> mappedInterceptors =
                   this.mappedInterceptors.getInterceptors(lookupPath, this.pathMatcher);
     if (!mappedInterceptors.isEmpty()) {
          HandlerExecutionChain chain;
          if (handler instanceof HandlerExecutionChain) {
                   chain = (HandlerExecutionChain) handler;
          }
          else {
                   chain = new HandlerExecutionChain(handler);
          }
          chain.addInterceptors(mappedInterceptors.toArray(new HandlerInterceptor[mappedInterceptors.size()]));
          // handler = chain; ???
     }
}

I tried this modification and works for me but may be I'm wrong.


Affects: 3.0.5

Issue Links:

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions