Hello. I have the following Request Interceptor, which sets my custom header on the requests. This works without problems when accessed from the Thread Local.
@Configuration
public class ConfigClass {
@Bean
public RequestInterceptor requestInterceptor() {
return requestTemplate -> {
ServletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
if(requestAttributes == null) return;
HttpServletRequest request = requestAttributes.getRequest();
String header = request.getHeader("CUSTOM_HEADER");
if(header !=null) requestTemplate.header("CUSTOM_HEADER", header)
This works perfectly fine when accessing mergods that are on the thread local. But when I access those merhods asynchronously, the header is null.
I also read that with SpringBoot 3.x onwards, we need to setup a configuration in order to propagate the local thread context to the async one. And I did the following from this github:
https://github.com/micrometer-metrics/tracing/wiki/Spring-Cloud-Sleuth-3.1-Migration-Guide
But it still is null. Can you please tell me if you know why this happens?
Thank you in advance!
Comment From: wilkinsona
Spring Boot doesn't do anything with Feign so I don't think this issue belongs here. If you're using Spring Cloud OpenFeign, https://github.com/spring-cloud/spring-cloud-openfeign/issues may be a better place, although it you're just looking for some help a question on Stack Overflow may be more appropriate.