From 5a06f3b150b0ab6305cca944973d07b094bf9005 Mon Sep 17 00:00:00 2001 From: Albumen Kevin Date: Mon, 26 Jun 2023 14:05:02 +0800 Subject: [PATCH] Skip catch SkipFailbackWrapperException in NacosRegistry --- .../dubbo/registry/nacos/NacosRegistry.java | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistry.java b/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistry.java index baaa2bf4377..893d77a061b 100644 --- a/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistry.java +++ b/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistry.java @@ -29,6 +29,7 @@ import org.apache.dubbo.registry.Registry; import org.apache.dubbo.registry.RegistryNotifier; import org.apache.dubbo.registry.support.FailbackRegistry; +import org.apache.dubbo.registry.support.SkipFailbackWrapperException; import org.apache.dubbo.rpc.RpcException; import com.alibaba.nacos.api.common.Constants; @@ -163,7 +164,9 @@ public List lookup(final URL url) { urls.addAll(buildURLs(url, instances)); } return urls; - } catch (Exception cause) { + } catch (SkipFailbackWrapperException exception) { + throw exception; + } catch (Exception cause) { throw new RpcException("Failed to lookup " + url + " from nacos " + getUrl() + ", cause: " + cause.getMessage(), cause); } } @@ -185,6 +188,8 @@ public void doRegister(URL url) { } else { logger.info("Please set 'dubbo.registry.parameters.register-consumer-url=true' to turn on consumer url registration."); } + } catch (SkipFailbackWrapperException exception) { + throw exception; } catch (Exception cause) { throw new RpcException("Failed to register " + url + " to nacos " + getUrl() + ", cause: " + cause.getMessage(), cause); } @@ -199,7 +204,9 @@ public void doUnregister(final URL url) { getUrl().getGroup(Constants.DEFAULT_GROUP), instance.getIp() , instance.getPort()); - } catch (Exception cause) { + } catch (SkipFailbackWrapperException exception) { + throw exception; + } catch (Exception cause) { throw new RpcException("Failed to unregister " + url + " to nacos " + getUrl() + ", cause: " + cause.getMessage(), cause); } } @@ -251,7 +258,9 @@ private void doSubscribe(final URL url, final NacosAggregateListener listener, f subscribeEventListener(serviceName, subscriberURL, listener); } } - } catch (Throwable cause) { + } catch (SkipFailbackWrapperException exception) { + throw exception; + } catch (Throwable cause) { throw new RpcException("Failed to subscribe " + url + " to nacos " + getUrl() + ", cause: " + cause.getMessage(), cause); } } @@ -355,7 +364,9 @@ private Set filterServiceNames(NacosServiceName serviceName) { .map(NacosServiceName::toString) .collect(Collectors.toList())); return serviceNames; - } catch (Throwable cause) { + } catch (SkipFailbackWrapperException exception) { + throw exception; + } catch (Throwable cause) { throw new RpcException("Failed to filter serviceName from nacos, url: " + getUrl() + ", serviceName: " + serviceName + ", cause: " + cause.getMessage(), cause); } } @@ -458,7 +469,9 @@ private Set getAllServiceNames() { serviceNames.addAll(listView.getData()); } return serviceNames; - } catch (Throwable cause) { + } catch (SkipFailbackWrapperException exception) { + throw exception; + } catch (Throwable cause) { throw new RpcException("Failed to get all serviceName from nacos, url: " + getUrl() + ", cause: " + cause.getMessage(), cause); } }