You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2021/04/30 00:55:50 UTC
[skywalking] branch master updated: perf: use iterator.remove() to
remove modulesWithoutProvider (#6874)
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking.git
The following commit(s) were added to refs/heads/master by this push:
new 83757da perf: use iterator.remove() to remove modulesWithoutProvider (#6874)
83757da is described below
commit 83757dae617f3ff5b0a61fc8985b859f28979974
Author: Wayne Chu <wa...@waynechu.cn>
AuthorDate: Fri Apr 30 08:55:22 2021 +0800
perf: use iterator.remove() to remove modulesWithoutProvider (#6874)
---
CHANGES.md | 1 +
.../starter/config/ApplicationConfigLoader.java | 22 ++++++----------------
2 files changed, 7 insertions(+), 16 deletions(-)
diff --git a/CHANGES.md b/CHANGES.md
index b4d8f7e..d92a777 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -31,6 +31,7 @@ Release Notes.
* Fix: Some defensive codes didn't work in `PercentileFunction combine`.
* CVE: fix Jetty vulnerability. https://nvd.nist.gov/vuln/detail/CVE-2019-17638
* Fix: MAL function would miss samples name after creating new samples.
+* perf: use iterator.remove() to remove modulesWithoutProvider
#### UI
* Add logo for kong plugin.
diff --git a/oap-server/server-bootstrap/src/main/java/org/apache/skywalking/oap/server/starter/config/ApplicationConfigLoader.java b/oap-server/server-bootstrap/src/main/java/org/apache/skywalking/oap/server/starter/config/ApplicationConfigLoader.java
index 31c874d..8bb2993 100644
--- a/oap-server/server-bootstrap/src/main/java/org/apache/skywalking/oap/server/starter/config/ApplicationConfigLoader.java
+++ b/oap-server/server-bootstrap/src/main/java/org/apache/skywalking/oap/server/starter/config/ApplicationConfigLoader.java
@@ -20,10 +20,9 @@ package org.apache.skywalking.oap.server.starter.config;
import java.io.FileNotFoundException;
import java.io.Reader;
-import java.util.HashSet;
+import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
-import java.util.Set;
import lombok.extern.slf4j.Slf4j;
import org.apache.skywalking.apm.util.PropertyPlaceholderHelper;
import org.apache.skywalking.oap.server.library.module.ApplicationConfiguration;
@@ -133,8 +132,9 @@ public class ApplicationConfigLoader implements ConfigLoader<ApplicationConfigur
}
private void selectConfig(final Map<String, Map<String, Object>> moduleConfiguration) {
- final Set<String> modulesWithoutProvider = new HashSet<>();
- for (final Map.Entry<String, Map<String, Object>> entry : moduleConfiguration.entrySet()) {
+ Iterator<Map.Entry<String, Map<String, Object>>> moduleIterator = moduleConfiguration.entrySet().iterator();
+ while (moduleIterator.hasNext()) {
+ Map.Entry<String, Map<String, Object>> entry = moduleIterator.next();
final String moduleName = entry.getKey();
final Map<String, Object> providerConfig = entry.getValue();
if (!providerConfig.containsKey(SELECTOR)) {
@@ -159,19 +159,9 @@ public class ApplicationConfigLoader implements ConfigLoader<ApplicationConfigur
}
// 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) {