wzhangNJ commented on issue #4157:
URL: https://github.com/apache/shenyu/issues/4157#issuecomment-1305116006

   shenyu的dubbo插件alibaba和apache 两个版本,
   AlibabaDubboServiceBeanListener的onApplicationEvent方法
   因为onApplicationEvent的这段代码导致了Map<String, ServiceBean> serviceBean = 
contextRefreshedEvent.getApplicationContext().getBeansOfType(ServiceBean.class);可能加载不进来
   ```
   if (!registered.compareAndSet(false, true)) {
               return;
           }
   ```
   我查看你了alibaba和apache两个版本的区别,发现apache的代码逻辑判断更严谨些
   
   shenyu apache dubbo 
   ```
   public void onApplicationEvent(final ContextRefreshedEvent 
contextRefreshedEvent) {
           // Fix bug(https://github.com/apache/shenyu/issues/415), upload 
dubbo metadata on ContextRefreshedEvent
           Map<String, ServiceBean> serviceBean = 
contextRefreshedEvent.getApplicationContext().getBeansOfType(ServiceBean.class);
           if (serviceBean.isEmpty()) {
               return;
           }
           if (!registered.compareAndSet(false, true)) {
               return;
           }
           for (Map.Entry<String, ServiceBean> entry : serviceBean.entrySet()) {
               handler(entry.getValue());
           }
           serviceBean.values().stream().findFirst().ifPresent(bean -> {
               publisher.publishEvent(buildURIRegisterDTO(bean));
           });
       }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to