From 718ec7cf68b59ae0076bcb2856abd3196cb56df2 Mon Sep 17 00:00:00 2001 From: "william.liangf" Date: Wed, 26 Oct 2011 06:49:51 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9zookeeper=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://code.alibabatech.com/svn/dubbo/trunk@72 1a56cb94-b969-4eaa-88fa-be21384802f2 --- .../registry/zookeeper/ZookeeperRegistry.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/dubbo-registry-zookeeper/src/main/java/com/alibaba/dubbo/registry/zookeeper/ZookeeperRegistry.java b/dubbo-registry-zookeeper/src/main/java/com/alibaba/dubbo/registry/zookeeper/ZookeeperRegistry.java index 076c1abc95..e80c3c7c44 100644 --- a/dubbo-registry-zookeeper/src/main/java/com/alibaba/dubbo/registry/zookeeper/ZookeeperRegistry.java +++ b/dubbo-registry-zookeeper/src/main/java/com/alibaba/dubbo/registry/zookeeper/ZookeeperRegistry.java @@ -59,6 +59,9 @@ public class ZookeeperRegistry implements Registry { private final ConcurrentMap> wathers = new ConcurrentHashMap>(); public ZookeeperRegistry(URL url) { + if (url == null) { + throw new IllegalArgumentException("registry url == null"); + } this.url = url; try { String address = url.getAddress(); @@ -98,6 +101,9 @@ public class ZookeeperRegistry implements Registry { } public void register(URL url) { + if (url == null) { + throw new IllegalArgumentException("register url == null"); + } try { String service = toServicePath(url); String provider = service + toProviderPath(url); @@ -113,6 +119,9 @@ public class ZookeeperRegistry implements Registry { } public void unregister(URL url) { + if (url == null) { + throw new IllegalArgumentException("unregister url == null"); + } try { String service = toServicePath(url); String provider = service + toProviderPath(url); @@ -123,6 +132,12 @@ public class ZookeeperRegistry implements Registry { } public void subscribe(URL url, NotifyListener listener) { + if (url == null) { + throw new IllegalArgumentException("subscribe url == null"); + } + if (listener == null) { + throw new IllegalArgumentException("subscribe listener == null"); + } try { String service = toServicePath(url); NotifyWatcher wather = new NotifyWatcher(this, url, listener); @@ -143,6 +158,12 @@ public class ZookeeperRegistry implements Registry { } public void unsubscribe(URL url, NotifyListener listener) { + if (url == null) { + throw new IllegalArgumentException("unsubscribe url == null"); + } + if (listener == null) { + throw new IllegalArgumentException("unsubscribe listener == null"); + } String service = toServicePath(url); Map serviceWathers = wathers.remove(service); if (serviceWathers != null && serviceWathers.size() > 0) { @@ -154,6 +175,9 @@ public class ZookeeperRegistry implements Registry { } public List lookup(URL url) { + if (url == null) { + throw new IllegalArgumentException("lookup url == null"); + } try { String service = toServicePath(url); List providers = zookeeper.getChildren(service, false);