Skip to content

AppInterceptorsHandler看代码一个问题,会导致公共拦截器和私有拦截器执行顺序混乱 #154

Closed
@Lingyuezhixing

Description

public RouteResponse intercept(Chain chain) {
.....
// record the position of the list at where the interceptors should be insert
int index = 0;

    // insert global interceptors in front of the queue
    if (!Router.getGlobalInterceptors().isEmpty()) {
        realChain.getInterceptors().addAll(index++, Router.getGlobalInterceptors());
       // 这里添加公有拦截器后index位置应该是公有拦截器总个数,
       //下面添加的私有拦截器才会正确的在所有公有拦截器执行完后再执行
    }
   
  .....

          // enqueue
          if (interceptor != null) {
                 realChain.getInterceptors().add(index++, interceptor);
          } 

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions