IcebergXTY commented on issue #1769: It does not support  dubbo v2.6.2+?
URL: 
https://github.com/apache/incubator-skywalking/issues/1769#issuecomment-432058349
 
 
   @wu-sheng Hey, I also met this problem and I found the reason. Because 
Skywalking will add `setSkyWalkingDynamicField(Object)` to class MonitorFilter 
and this conflicts with dubbo's spi extention mechanism. 
   ```java
   /*
    * com.alibaba.dubbo.monitor.support.MonitorFilter
    * Here dubbo's spi extention mechanism will traverse all the public set 
method
    */
   private T injectExtension(T instance) {
       try {
           if (objectFactory != null) {
               for (Method method : instance.getClass().getMethods()) {
                   if (method.getName().startsWith("set")
                           && method.getParameterTypes().length == 1
                           && Modifier.isPublic(method.getModifiers())) {
                       Class<?> pt = method.getParameterTypes()[0];
                       try {
                           String property = method.getName().length() > 3 ? 
method.getName().substring(3, 4).toLowerCase() + method.getName().substring(4) 
: "";
                           Object object = objectFactory.getExtension(pt, 
property);
                           if (object != null) {
                               method.invoke(instance, object);
                           }
                       } catch (Exception e) {
                           logger.error("fail to inject via method " + 
method.getName()
                                   + " of interface " + type.getName() + ": " + 
e.getMessage(), e);
                       }
                   }
               }
           }
       } catch (Exception e) {
           logger.error(e.getMessage(), e);
       }
       return instance;
   }
   ```
   Before dubbo 2.6.3, the extentionFactory just get bean by name, so there is 
no errro.
   ```java
   /*
    * com.alibaba.dubbo.config.spring.extension.SpringExtensionFactory
    */
   @Override
   @SuppressWarnings("unchecked")
   public <T> T getExtension(Class<T> type, String name) {
       for (ApplicationContext context : contexts) {
           if (context.containsBean(name)) {
               Object bean = context.getBean(name);
               if (type.isInstance(bean)) {
                   return (T) bean;
               }
           }
       }
       return null;
   }
   ```
   After, dubbo monify the code, it also get bean by type and this throw the 
exception.
   ```java
   @Override
   @SuppressWarnings("unchecked")
   public <T> T getExtension(Class<T> type, String name) {
       for (ApplicationContext context : contexts) {
           if (context.containsBean(name)) {
               Object bean = context.getBean(name);
               if (type.isInstance(bean)) {
                   return (T) bean;
               }
           }
       }
   
       logger.warn("No spring extension(bean) named:" + name + ", try to find 
an extension(bean) of type " + type.getName());
   
       for (ApplicationContext context : contexts) {
           try {
               return context.getBean(type);
           } catch (NoUniqueBeanDefinitionException multiBeanExe) {
               //here will throw exception because setSkyWalkingDynamicField() 
type is Object and spring will find many beans
               throw multiBeanExe;
           } catch (NoSuchBeanDefinitionException noBeanExe) {
               if (logger.isDebugEnabled()) {
                   logger.debug("Error when get spring extension(bean) for 
type:" + type.getName(), noBeanExe);
               }
           }
       }
   
       logger.warn("No spring extension(bean) named:" + name + ", type:" + 
type.getName() + " found, stop get bean.");
   
       return null;
   }
   ```
   Emmm....Maybe you can communicate with dubbo....

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to