注册器JpushInterceptor
功能:新版的Java推送服务,将部分请求转发到老版node
查看日志发现拦截器日志重复
同一个链路,发现,经过同一个拦截器两次
debug发现注册器重复注册
第一个通过registry.addInterceptor注册
是通过WebMvcConfigurer的钩子注册的
第二个通过bean类型中注册
因为使用了op3(公司内部对Spring二次开发的),版本:3.2.3.RELEASE
通过@Component将JpushInterceptor声明为了Spring Bean
OpWebAutoConfiguration通过beanType将其注册,链路如下:
DelegatingWebMvcConfiguration.requestMappingHandlerMapping()
-> getInterceptors()
…
-> OpWebAutoConfiguration.addInterceptors

关于通过bean类型方式的注册
spring文档上描述,支持的拦截器注册的方法只有下面的方式(即同上述第一种方式,通过javaconfig或者xml配置)
https://docs.spring.io/spring-framework/docs/current/reference/html/web.html#mvc-config-interceptors
并不支持上述根据bean类型注册。
op3支持按类型,自动注册拦截器
看op4上面的代码已经没了
解决方案
移除JpushInterceptor上的@Component注解
- 本周二上预发,周四发布生产
结论
公司内对Spring二次开发,但个别情况没有考虑周全,用户代码总是千奇百怪的