startjava commented on issue #8403:
URL: https://github.com/apache/dubbo/issues/8403#issuecomment-891725833


   @BurningCN 
   
   如下代码:
       @Override
       public void register(URL url) {
           if (!acceptable(url)) {
               logger.info("URL " + url + " will not be registered to Registry. 
Registry " + url + " does not accept service of this protocol type.");
               return;
           }
           super.register(url);
           removeFailedRegistered(url);
           removeFailedUnregistered(url);
           try {
               // Sending a registration request to the server side
               doRegister(url);
   
   中的 doRegister(url);方法,会调用如下代码:
   public class NacosRegistry extends FailbackRegistry {
   
       private void execute(NamingServiceCallback callback) {
           try {
               callback.callback(namingService);
           } catch (NacosException e) {
               if (logger.isErrorEnabled()) {
                   logger.error(e.getErrMsg(), e);
               }
           }
       }
   
   方法callback如果出现异常,则execute方法就吃掉异常了,不会向上throw抛出异常,导致进不了如下代码中的catch:
           try {
               // Sending a registration request to the server side
               doRegister(url);
           } catch (Exception e) {
               Throwable t = e;
   
               // If the startup detection is opened, the Exception is thrown 
directly.
               boolean check = getUrl().getParameter(Constants.CHECK_KEY, true)
                       && url.getParameter(Constants.CHECK_KEY, true)
                       && !(url.getPort() == 0);
               boolean skipFailback = t instanceof SkipFailbackWrapperException;
               if (check || skipFailback) {
                   if (skipFailback) {
                       t = t.getCause();
                   }
                   throw new IllegalStateException("Failed to register " + url 
+ " to registry " + getUrl().getAddress() + ", cause: " + t.getMessage(), t);
               } else {
                   logger.error("Failed to register " + url + ", waiting for 
retry, cause: " + t.getMessage(), t);
               }
   
               // Record a failed registration request to a failed list, retry 
regularly
               addFailedRegistered(url);
           }
   
   不知道我分析的对不对,我是调试搞的,不会进入catch,也就不会执行if check判断代码了。


-- 
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]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to