lordcheng10 commented on code in PR #17035:
URL: https://github.com/apache/pulsar/pull/17035#discussion_r963329437


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java:
##########
@@ -2113,33 +2114,44 @@ private void handlePoliciesUpdates(NamespaceName 
namespace) {
     }
 
     private void handleDynamicConfigurationUpdates() {
-        
pulsar().getPulsarResources().getDynamicConfigResources().getDynamicConfigurationAsync()
-                .thenAccept(optMap -> {
-                    if (!optMap.isPresent()) {
-                        return;
-                    }
-                    Map<String, String> data = optMap.get();
-                    data.forEach((configKey, value) -> {
-                        Field configField = 
dynamicConfigurationMap.get(configKey).field;
-                        Object newValue = 
FieldParser.value(data.get(configKey), configField);
-                        if (configField != null) {
-                            Consumer listener = 
configRegisteredListeners.get(configKey);
-                            try {
-                                Object existingValue = 
configField.get(pulsar.getConfiguration());
-                                configField.set(pulsar.getConfiguration(), 
newValue);
-                                log.info("Successfully updated configuration 
{}/{}", configKey,
-                                        data.get(configKey));
-                                if (listener != null && 
!existingValue.equals(newValue)) {
-                                    listener.accept(newValue);
+        DynamicConfigurationResources dynamicConfigResources = null;
+        try {
+            dynamicConfigResources = pulsar()
+                    .getPulsarResources()
+                    .getDynamicConfigResources();

Review Comment:
   1. This is just to get the object, it will not block the thread.
   2. The try catch here is just to catch the situation where 
getPulsarResources or getDynamicConfigResources returns null, because some unit 
tests do not initialize pulsarResources or dynamicConfigResources.
   3. Try catch is also performed in the original call of 
updateDynamicServiceConfiguration:
   <img width="1010" alt="image" 
src="https://user-images.githubusercontent.com/19296967/188568999-c3e6aa55-c94d-4e1e-8514-4955b0651d44.png";>
   



-- 
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