mattisonchao commented on a change in pull request #14087:
URL: https://github.com/apache/pulsar/pull/14087#discussion_r800472595



##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/BrokersBase.java
##########
@@ -235,31 +242,25 @@ public void 
deleteDynamicConfiguration(@PathParam("configName") String configNam
      * @param configValue
      *            : configuration value
      */
-    private synchronized void persistDynamicConfiguration(String configName, 
String configValue) {
-        try {
-            if (!BrokerService.validateDynamicConfiguration(configName, 
configValue)) {
-                throw new RestException(Status.PRECONDITION_FAILED, " Invalid 
dynamic-config value");
-            }
-            if (BrokerService.isDynamicConfiguration(configName)) {
-                
dynamicConfigurationResources().setDynamicConfigurationWithCreate(old -> {
-                    Map<String, String> configurationMap = old.isPresent() ? 
old.get() : Maps.newHashMap();
-                    configurationMap.put(configName, configValue);
-                    return configurationMap;
-                });
-                LOG.info("[{}] Updated Service configuration {}/{}", 
clientAppId(), configName, configValue);
-            } else {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("[{}] Can't update non-dynamic configuration 
{}/{}", clientAppId(), configName,
-                            configValue);
-                }
-                throw new RestException(Status.PRECONDITION_FAILED, " Can't 
update non-dynamic configuration");
+    private synchronized CompletableFuture<Void> 
persistDynamicConfigurationAsync(
+            String configName, String configValue) {
+        if (!BrokerService.validateDynamicConfiguration(configName, 
configValue)) {
+            return FutureUtil
+                    .failedFuture(new 
RestException(Status.PRECONDITION_FAILED, " Invalid dynamic-config value"));
+        }
+        if (BrokerService.isDynamicConfiguration(configName)) {
+            return 
dynamicConfigurationResources().setDynamicConfigurationWithCreateAsync(old -> {
+                Map<String, String> configurationMap = 
old.orElseGet(Maps::newHashMap);
+                configurationMap.put(configName, configValue);
+                return configurationMap;
+            });
+        } else {
+            if (LOG.isDebugEnabled()) {

Review comment:
       Sure, thanks to you.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to