Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zipkin can not report the span to kafka when project utilize swagge-3.0.0 #3478

Open
Layfolk-zcy opened this issue Sep 28, 2022 · 0 comments
Labels

Comments

@Layfolk-zcy
Copy link

Layfolk-zcy commented Sep 28, 2022

springBoot>2.6.3
<spring-cloud-dependencies.version>2021.0.1
<spring-cloud-alibaba-dependencies.version>2021.0.1.0

springfox-boot-starter>3.0.0
phenomenon:

when i put the springfox dependency into project, which the kafka server cant recept the span message. After i try remove springfox dependency the kafka server ,which working i wished.

when swagger integrate springBoot 2.6.3 , i refer some blogs added some Bean because springboot 2.6.3 uncompatible sprignfox 3.0.0 triggered some exceptions . Such as:

`

@component
public class SwaggerBeanPostProcessor implements BeanPostProcessor {

  @Override
  public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
      if (bean instanceof WebMvcRequestHandlerProvider || bean instanceof WebFluxRequestHandlerProvider)
      {
          List<RequestMappingInfoHandlerMapping> handlerMappings = getHandlerMappings(bean);
          customizeSpringfoxHandlerMappings(handlerMappings);
      }
      return bean;
  }

  private <T extends RequestMappingInfoHandlerMapping> void customizeSpringfoxHandlerMappings(List<T> mappings) {
      List<T> copy = mappings.stream()
              .filter(mapping -> mapping.getPatternParser() == null)
              .collect(Collectors.toList());
      mappings.clear();
      mappings.addAll(copy);
  }

  @SuppressWarnings("unchecked")
  private List<RequestMappingInfoHandlerMapping> getHandlerMappings(Object bean) {
      try {
          Field field = ReflectionUtils.findField(bean.getClass(), "handlerMappings");
          field.setAccessible(true);
          return (List<RequestMappingInfoHandlerMapping>) field.get(bean);
      }
      catch (IllegalArgumentException | IllegalAccessException e) {
          throw new IllegalStateException(e);
      }
  }

}

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant