未验证 提交 83757dae 编写于 作者: W Wayne Chu 提交者: GitHub

perf: use iterator.remove() to remove modulesWithoutProvider (#6874)

上级 4ecf7ff1
...@@ -31,6 +31,7 @@ Release Notes. ...@@ -31,6 +31,7 @@ Release Notes.
* Fix: Some defensive codes didn't work in `PercentileFunction combine`. * Fix: Some defensive codes didn't work in `PercentileFunction combine`.
* CVE: fix Jetty vulnerability. https://nvd.nist.gov/vuln/detail/CVE-2019-17638 * CVE: fix Jetty vulnerability. https://nvd.nist.gov/vuln/detail/CVE-2019-17638
* Fix: MAL function would miss samples name after creating new samples. * Fix: MAL function would miss samples name after creating new samples.
* perf: use iterator.remove() to remove modulesWithoutProvider
#### UI #### UI
* Add logo for kong plugin. * Add logo for kong plugin.
......
...@@ -20,10 +20,9 @@ package org.apache.skywalking.oap.server.starter.config; ...@@ -20,10 +20,9 @@ package org.apache.skywalking.oap.server.starter.config;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.Reader; import java.io.Reader;
import java.util.HashSet; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.Set;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.skywalking.apm.util.PropertyPlaceholderHelper; import org.apache.skywalking.apm.util.PropertyPlaceholderHelper;
import org.apache.skywalking.oap.server.library.module.ApplicationConfiguration; import org.apache.skywalking.oap.server.library.module.ApplicationConfiguration;
...@@ -133,8 +132,9 @@ public class ApplicationConfigLoader implements ConfigLoader<ApplicationConfigur ...@@ -133,8 +132,9 @@ public class ApplicationConfigLoader implements ConfigLoader<ApplicationConfigur
} }
private void selectConfig(final Map<String, Map<String, Object>> moduleConfiguration) { private void selectConfig(final Map<String, Map<String, Object>> moduleConfiguration) {
final Set<String> modulesWithoutProvider = new HashSet<>(); Iterator<Map.Entry<String, Map<String, Object>>> moduleIterator = moduleConfiguration.entrySet().iterator();
for (final Map.Entry<String, Map<String, Object>> entry : moduleConfiguration.entrySet()) { while (moduleIterator.hasNext()) {
Map.Entry<String, Map<String, Object>> entry = moduleIterator.next();
final String moduleName = entry.getKey(); final String moduleName = entry.getKey();
final Map<String, Object> providerConfig = entry.getValue(); final Map<String, Object> providerConfig = entry.getValue();
if (!providerConfig.containsKey(SELECTOR)) { if (!providerConfig.containsKey(SELECTOR)) {
...@@ -159,19 +159,9 @@ public class ApplicationConfigLoader implements ConfigLoader<ApplicationConfigur ...@@ -159,19 +159,9 @@ public class ApplicationConfigLoader implements ConfigLoader<ApplicationConfigur
} }
// now the module can be safely removed // now the module can be safely removed
modulesWithoutProvider.add(moduleName); moduleIterator.remove();
log.info("Remove module {} without any provider", moduleName);
} }
moduleConfiguration.entrySet().removeIf(e -> {
final String module = e.getKey();
final boolean shouldBeRemoved = modulesWithoutProvider.contains(module);
if (shouldBeRemoved) {
log.info("Remove module {} without any provider", module);
}
return shouldBeRemoved;
});
} }
private void overrideModuleSettings(ApplicationConfiguration configuration, String key, String value) { private void overrideModuleSettings(ApplicationConfiguration configuration, String key, String value) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册