Skip to content

Commit

Permalink
Merge branch 'main' into dev-force-nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
loongs-zhang authored Jan 8, 2024
2 parents 9514964 + 15b2ac2 commit de61a77
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions registry/zookeeper/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use dubbo_base::{
use dubbo_logger::tracing::{debug, error, info};
use serde::{Deserialize, Serialize};
#[allow(unused_imports)]
use zookeeper::{Acl, CreateMode, WatchedEvent, WatchedEventType, Watcher, ZooKeeper};
use zookeeper::{Acl, CreateMode, WatchedEvent, WatchedEventType, Watcher, ZkError, ZooKeeper};

use dubbo::{
registry::{
Expand Down Expand Up @@ -153,7 +153,7 @@ impl ZookeeperRegistry {
match zk_result {
Ok(_) => Ok(()),
Err(err) => {
error!("zk path {} parent not exists.", path);
error!("create path {} to zookeeper error {}", path, err);
Err(Box::try_from(err).unwrap())
}
}
Expand Down Expand Up @@ -184,8 +184,20 @@ impl ZookeeperRegistry {
true => data,
false => "",
};
self.create_path(current.as_str(), new_data, new_create_mode)
.unwrap();

//Skip ZkError::NodeExists
let res = self.create_path(current.as_str(), new_data, new_create_mode);
let mut node_exist = false;
if let Err(e) = &res {
if let Some(zk_err) = e.downcast_ref::<ZkError>() {
if ZkError::NodeExists == *zk_err {
node_exist = true;
}
}
}
if !node_exist {
return res;
}
}
}
Ok(())
Expand Down

0 comments on commit de61a77

Please sign in to comment.