This is an automated email from the ASF dual-hosted git repository.
wangdan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pegasus.git
The following commit(s) were added to refs/heads/master by this push:
new c1788c3db fix: fix recall_app with default app_name (#1942)
c1788c3db is described below
commit c1788c3db37ca4d2ff2d55e3d3ca6b667575a95b
Author: Guohao Li <[email protected]>
AuthorDate: Tue Mar 12 11:41:27 2024 +0800
fix: fix recall_app with default app_name (#1942)
---
src/client/replication_ddl_client.cpp | 9 +++++----
src/client/replication_ddl_client.h | 2 +-
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/client/replication_ddl_client.cpp
b/src/client/replication_ddl_client.cpp
index 15dc4fec6..d80ac9f52 100644
--- a/src/client/replication_ddl_client.cpp
+++ b/src/client/replication_ddl_client.cpp
@@ -72,9 +72,11 @@ namespace replication {
using tp_output_format = ::dsn::utils::table_printer::output_format;
-error_s replication_ddl_client::validate_app_name(const std::string &app_name)
+error_s replication_ddl_client::validate_app_name(const std::string &app_name,
+ bool allow_empty_name)
{
- if (app_name.empty() || !std::all_of(app_name.cbegin(), app_name.cend(),
[](const char c) {
+ if ((app_name.empty() && !allow_empty_name) ||
+ !std::all_of(app_name.cbegin(), app_name.cend(), [](const char c) {
return static_cast<bool>(std::isalnum(c)) || c == '_' || c == '.'
|| c == ':';
})) {
return FMT_ERR(ERR_INVALID_PARAMETERS, "Invalid name: Only
0-9a-zA-Z.:_ are valid.");
@@ -227,8 +229,7 @@ dsn::error_code replication_ddl_client::drop_app(const
std::string &app_name, in
dsn::error_code replication_ddl_client::recall_app(int32_t app_id, const
std::string &new_app_name)
{
RETURN_EC_NOT_OK_MSG(
- validate_app_name(new_app_name), "invalid new_app_name: '{}'",
new_app_name);
-
+ validate_app_name(new_app_name, true), "invalid new_app_name: '{}'",
new_app_name);
auto req = std::make_shared<configuration_recall_app_request>();
req->app_id = app_id;
req->new_app_name = new_app_name;
diff --git a/src/client/replication_ddl_client.h
b/src/client/replication_ddl_client.h
index 38b94a6e1..b72d982f0 100644
--- a/src/client/replication_ddl_client.h
+++ b/src/client/replication_ddl_client.h
@@ -265,7 +265,7 @@ public:
void set_max_wait_app_ready_secs(uint32_t max_wait_secs) { _max_wait_secs
= max_wait_secs; }
- static error_s validate_app_name(const std::string &app_name);
+ static error_s validate_app_name(const std::string &app_name, bool
allow_empty_name = false);
private:
bool static valid_app_char(int c);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]