我们鼓励使用英文,如果不能直接使用,可以使用翻译软件,您仍旧可以保留中文原文。
We recommend using English. If you are non-native English speaker, you can use the translation software.
Which Component
eg. Nacos Discovery, Sentinel
spring-cloud-alibaba-dubbo 2.1.1.RELEASE
spring-cloud-dependencies Hoxton.SR1
spring-boot 2.2.2.RELEASE
Describe the bug
A clear and concise description of what the bug is.
如果采用dubbo替换feign client的http协议,ReferenceBean在底层初始化filter chain的时候,TracingFilter的setTracing方法注入了一个null值,根本原因是ExtensionLoader委托SpringExtensionFactory获取bean对象失败(因为SpringExtensionFactory还没来得及给CONTEXTS初始化)
1.必须强制@DubboTransported(filter = {"tracing"})才可以使用tracing(前提条件是使用dubbo协议替换feign的http协议),而配置文件里面的dubbo.consumer.filter或dubbo.provider.filter不起作用
2.ExtensionLoader执行inject操作,注入的tracing对象是委托给SpringExtensionFactory从context里面获取,但是ExtensionLoader inject操作在SpringExtensionFactory context还未初始化之前就执行了,导致SpringExtensionFactory不能从context获取bean,也就导致inject了一个null值
To Reproduce
Steps to reproduce the behavior:
- 源码在这里 spring-cloud-alibaba-example
- 启动zipkin
- 启动nacos
- 启动server服务
- 启动client服务
- 访问 http://localhost:9001/echo?message=xxx
解决方案:
@FeignClient(name = "spring-cloud-alibaba-server")
public interface EchoService {
@RequestMapping(value = "/echo")
@DubboTransported(filter = {"tracing"})
String echo(@RequestParam("message") String message);
}
@Component
@Order(value = Ordered.HIGHEST_PRECEDENCE)
public class CustomContextAware implements ApplicationContextAware {
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
SpringExtensionFactory.addApplicationContext(applicationContext);
}
}
Expected behavior
A clear and concise description of what you expected to happen.
1.如果不给SpringExtensionFactory初始化一些context,那么tracing是不起作用的,因为brave.dubbo.TracingFilter内部的tracing是一个null值
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Add any other context about the problem here.
e.g. MacOS 、Java8 、 Version 0.2.1.RELEASE
2条答案
按热度按时间xwbd5t1u1#
鼓励使用英文, 是因为想把阿里云打入国外市场?
waxmsbnn2#
鼓励使用英文, 是因为想把阿里云打入国外市场?
我觉得国际化很有必要,在国内自娱自乐也没啥意思,要让老外感受感受爸爸们的温暖,手动狗头doge