BewareMyPower commented on a change in pull request #13420:
URL: https://github.com/apache/pulsar/pull/13420#discussion_r774362146
##########
File path:
pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/DynamicConfigurationResources.java
##########
@@ -41,7 +41,7 @@ public DynamicConfigurationResources(MetadataStore store, int
operationTimeoutSe
}
public Map<String, String> getDynamicConfiguration() throws
MetadataStoreException {
- return
get(BROKER_SERVICE_CONFIGURATION_PATH).orElse(Collections.emptyMap());
+ return get(BROKER_SERVICE_CONFIGURATION_PATH).orElse(null);
Review comment:
It changes the original behavior. This method is also used in
`BrokersBase#getAllDynamicConfigurations`. Maybe it doesn't affect, but I think
it's better to keep the current semantic unchanged.
I'd prefer to return an optional object for this method so that the
synchronous method `getDynamicConfiguration` will be consistent with the
asynchronous method `getDynamicConfigurationAsync`.
```java
public Optional<Map<String, String>> getDynamicConfiguration() throws
MetadataStoreException {
return get(BROKER_SERVICE_CONFIGURATION_PATH);
}
```
Then in `BrokerService#updateDynamicServiceConfiguration`, we can call it
like
```java
configCache =
pulsar().getPulsarResources().getDynamicConfigResources().getDynamicConfiguration();
// create dynamic-config if not exist.
if (!configCache.isPresent()) {
```
It's more clear than null check. And in
`BrokerBase#getAllDynamicConfigurations`, we can simply keep the original
implementation like
```java
return
dynamicConfigurationResources().getDynamicConfiguration().orElse(Collections.emptyMap());
```
--
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]