Fix issue 6945 (#6948)
This commit is contained in:
parent
86dab08354
commit
5e40a0998a
|
|
@ -41,6 +41,7 @@ Release Notes.
|
|||
* Fix: Envoy error logs are not persisted when no metrics are generated
|
||||
* Fix: Memory leakage of low version etcd client. [fix-issue](https://github.com/jurmous/etcd4j/pull/185)
|
||||
* Allow multiple definitions as fallback in metadata-service-mapping.yaml file.
|
||||
* Fix: NPE when configmap has no data.
|
||||
|
||||
#### UI
|
||||
* Add logo for kong plugin.
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ public class ConfigmapConfigurationWatcherRegister extends ConfigWatcherRegister
|
|||
final ConfigTable configTable = new ConfigTable();
|
||||
Optional<V1ConfigMap> v1ConfigMap = informer.configMap();
|
||||
for (final String name : keys) {
|
||||
final String value = v1ConfigMap.map(configMap -> configMap.getData().get(name)).orElse(null);
|
||||
final String value = v1ConfigMap.map(V1ConfigMap::getData).map(data -> data.get(name)).orElse(null);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("read config: name:{} ,value:{}", name, value);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,6 +57,19 @@ public class ConfigmapConfigWatcherRegisterTest {
|
|||
register = new ConfigmapConfigurationWatcherRegister(settings, informer);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readConfigWhenConfigMapDataIsNull() throws Exception {
|
||||
V1ConfigMap v1ConfigMap = new V1ConfigMap();
|
||||
PowerMockito.doReturn(Optional.of(v1ConfigMap)).when(informer).configMap();
|
||||
Optional<ConfigTable> optionalConfigTable = register.readConfig(new HashSet<String>() {{
|
||||
add("key1");
|
||||
}});
|
||||
|
||||
Assert.assertTrue(optionalConfigTable.isPresent());
|
||||
ConfigTable configTable = optionalConfigTable.get();
|
||||
Assert.assertEquals(configTable.getItems().size(), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readConfigWhenInformerNotwork() throws Exception {
|
||||
PowerMockito.doReturn(Optional.empty()).when(informer).configMap();
|
||||
|
|
|
|||
Loading…
Reference in New Issue