apache / apache/dubbo-samples

dubbo-samples-zipkin test failed on 2.7.9

Open
#272 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
2.4k
Forks
2k
PR merge metrics
No merged PRs in 30d

Description

The direct problem is that the zipkin `TracingFilter` failed to inject the brave.Tracer instance (ie the bean named 'tracing') when the greeting-service app was started.

After analyzing the initialization process of TracingFilter, it is found that it uses `com.alibaba.spring.util.BeanFactoryUtils#getOptionalBean` to find the required tracing bean, and this method **will only find the bean that has been initialized and will not initialize a new instance.**

Compared with 2.7.7/2.7.8, found this change from 2.7.8. In 2.7.7 and before, `BeanFactoryUtils#getOptionalBean` will auto create new instance.

In 2.7.7 which depends on `spring-context-support:1.0.6`:
```
public static List getBeans(ListableBeanFactory beanFactory, String[] beanNames, Class beanType) {

if (isEmpty(beanNames)) {
return emptyList();
}

String[] allBeanNames = beanNamesForTypeIncludingAncestors(beanFactory, beanType);

List beans = new ArrayList(beanNames.length);

for (String beanName : beanNames) {
if (containsElement(allBeanNames, beanName)) {
beans.add(beanFactory.getBean(beanName, beanType));
}
}

return unmodifiableList(beans);
}
```

In 2.7.8 which depends on `spring-context-support:1.0.8`:
```java
public static List getBeans(ListableBeanFactory beanFactory, String[] beanNames, Class beanType) {

if (isEmpty(beanNames)) {
return emptyList();
}

// Issue : https://github.com/alibaba/spring-context-support/issues/20
String[] allBeanNames = beanNamesForTypeIncludingAncestors(beanFactory, beanType, true, false);

List beans = new ArrayList(beanNames.length);

for (String beanName : beanNames) {
if (containsElement(allBeanNames, beanName)) {
beans.add(beanFactory.getBean(beanName, beanType));
}
}

return unmodifiableList(beans);
}
```

Related issue: https://github.com/alibaba/spring-context-support/issues/20

I think we can optimize the dependency of the filters, by using spring bean `depends-on` to solve the filter initialization order. Ensure that the filter bean is initialized before dubbo service/reference bean.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.