Skip to content

Commit

Permalink
check curator event with empty data value (#4126)
Browse files Browse the repository at this point in the history
fixes #3866
  • Loading branch information
cvictory authored and chickenlj committed May 23, 2019
1 parent ebafc18 commit 5285952
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package org.apache.dubbo.remoting.zookeeper.curator;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.StringUtils;
import org.apache.dubbo.remoting.zookeeper.ChildListener;
import org.apache.dubbo.remoting.zookeeper.DataListener;
Expand Down Expand Up @@ -49,6 +51,8 @@

public class CuratorZookeeperClient extends AbstractZookeeperClient<CuratorZookeeperClient.CuratorWatcherImpl, CuratorZookeeperClient.CuratorWatcherImpl> {

protected static final Logger logger = LoggerFactory.getLogger(CuratorZookeeperClient.class);

static final Charset CHARSET = Charset.forName("UTF-8");
private final CuratorFramework client;
private Map<String, TreeCache> treeCacheMap = new ConcurrentHashMap<>();
Expand Down Expand Up @@ -288,6 +292,9 @@ public void process(WatchedEvent event) throws Exception {
@Override
public void childEvent(CuratorFramework client, TreeCacheEvent event) throws Exception {
if (dataListener != null) {
if (logger.isInfoEnabled()) {
logger.info("listen the zookeeper changed. The changed data:" + event.getData());
}
TreeCacheEvent.Type type = event.getType();
EventType eventType = null;
String content = null;
Expand All @@ -296,12 +303,12 @@ public void childEvent(CuratorFramework client, TreeCacheEvent event) throws Exc
case NODE_ADDED:
eventType = EventType.NodeCreated;
path = event.getData().getPath();
content = new String(event.getData().getData(), CHARSET);
content = event.getData().getData() == null ? "" : new String(event.getData().getData(), CHARSET);
break;
case NODE_UPDATED:
eventType = EventType.NodeDataChanged;
path = event.getData().getPath();
content = new String(event.getData().getData(), CHARSET);
content = event.getData().getData() == null ? "" : new String(event.getData().getData(), CHARSET);
break;
case NODE_REMOVED:
path = event.getData().getPath();
Expand Down

0 comments on commit 5285952

Please sign in to comment.