Fix `ZookeeperConfigWatcherRegister.readConfig()` could cause `NPE` when `data.getData()` is null (#7611)

This commit is contained in:
wankai123 2021-08-31 08:39:28 +08:00 committed by GitHub
parent eb7fae2ef2
commit 313edd3097
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -48,6 +48,7 @@ Release Notes.
by `agent-analyzer.default.traceSamplingPolicySettingsFile`.
* Fix dynamic configuration watch implementation current value not null when the config is deleted.
* Fix `LoggingConfigWatcher` return `watch.value` would not consistent with the real configuration content.
* Fix `ZookeeperConfigWatcherRegister.readConfig()` could cause `NPE` when `data.getData()` is null.
#### UI

View File

@ -52,7 +52,11 @@ public class ZookeeperConfigWatcherRegister extends ConfigWatcherRegister {
ConfigTable table = new ConfigTable();
keys.forEach(s -> {
ChildData data = this.childrenCache.getCurrentData(this.prefix + s);
table.add(new ConfigTable.ConfigItem(s, data == null ? null : new String(data.getData())));
String itemValue = null;
if (data != null && data.getData() != null) {
itemValue = new String(data.getData());
}
table.add(new ConfigTable.ConfigItem(s, itemValue));
});
return Optional.of(table);
}