JsonLYH opened a new issue, #32031:
URL: https://github.com/apache/shardingsphere/issues/32031

   
![344406599-acb55a73-2bb6-47ab-9aea-23000354cee7](https://github.com/apache/shardingsphere/assets/64977775/c7e5d559-d38e-4093-9940-9d89c492338b)
   
![shardingjdbc+seata问题pr](https://github.com/apache/shardingsphere/assets/64977775/58626409-cb27-4c00-abd0-4e21d7190050)
   ### I configured the interceptor accordingly. It didn't work
   @Configuration
   @Slf4j
   public class WebMVCConfig implements WebMvcConfigurer {
   
       @Autowired
       private LoginRequestInterceptor loginRequestInterceptor;
   
       @Override
       public void addInterceptors(InterceptorRegistry registry) {
   
           registry.addInterceptor(loginRequestInterceptor)
                   .addPathPatterns("/**");
           registry.addInterceptor(new 
SeataFeignInterceptor()).addPathPatterns("/**");
       }
       @Bean
       public ApiIdempotentInterceptor apiIdempotentInterceptor() {
           return new ApiIdempotentInterceptor();
       }
   
       public static class SeataFeignInterceptor implements HandlerInterceptor {
   
           @Override
           public boolean preHandle(HttpServletRequest request, 
HttpServletResponse response, Object handler) throws Exception {
               String xid = RootContext.getXID();
               if (xid == null) {
                   xid = request.getHeader(RootContext.KEY_XID);
                   if(xid == null) {
                       xid = request.getHeader("tx_xid");
                   }
               }
   
               if (!StringUtils.isBlank(xid) && SeataTransactionHolder.get() == 
null) {
                   RootContext.bind(xid);
                   
SeataTransactionHolder.set(GlobalTransactionContext.getCurrentOrCreate());
               }else if(!StringUtils.isBlank(xid)){
                   RootContext.bind(xid);
               }
   
               return true;
           }
       }
   }
   ### The current version I'm using
   sharding-jdbc-spring-boot-starter 4.1.1
   sharding-transaction-base-seata-at  4.1.1
   seata 2.0.0
   
   **postman calls a microservice directly, which is normal and does not report 
an error, but calls through feign will report a null pointer exception, I 
confirm that tx_id has been passed normally**


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: 
[email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to