You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2022/04/27 15:31:40 UTC

[servicecomb-java-chassis] branch master updated: [SCB-2466] Fix spotbugs WMI_WRONG_MAP_ITERATOR (#2803)

This is an automated email from the ASF dual-hosted git repository.

liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git


The following commit(s) were added to refs/heads/master by this push:
     new 71ff5c005 [SCB-2466] Fix spotbugs WMI_WRONG_MAP_ITERATOR (#2803)
71ff5c005 is described below

commit 71ff5c0058e5e04be30d2e1ab1d4e80e40ceb034
Author: ZhangJian He <sh...@gmail.com>
AuthorDate: Wed Apr 27 23:31:34 2022 +0800

    [SCB-2466] Fix spotbugs WMI_WRONG_MAP_ITERATOR (#2803)
---
 ci/spotbugs/exclude.xml                                        |  4 ----
 .../servicecomb/config/common/ConfigurationChangedEvent.java   |  7 ++++---
 .../main/java/org/apache/servicecomb/config/ConfigUtil.java    | 10 ++++++----
 3 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/ci/spotbugs/exclude.xml b/ci/spotbugs/exclude.xml
index d37d28e2b..b6d4626b9 100644
--- a/ci/spotbugs/exclude.xml
+++ b/ci/spotbugs/exclude.xml
@@ -191,8 +191,4 @@
         <Bug pattern="VA_FORMAT_STRING_USES_NEWLINE"/>
     </Match>
 
-    <Match>
-        <Bug pattern="WMI_WRONG_MAP_ITERATOR"/>
-    </Match>
-
 </FindBugsFilter>
diff --git a/clients/config-common/src/main/java/org/apache/servicecomb/config/common/ConfigurationChangedEvent.java b/clients/config-common/src/main/java/org/apache/servicecomb/config/common/ConfigurationChangedEvent.java
index a3514d004..e24d061a6 100644
--- a/clients/config-common/src/main/java/org/apache/servicecomb/config/common/ConfigurationChangedEvent.java
+++ b/clients/config-common/src/main/java/org/apache/servicecomb/config/common/ConfigurationChangedEvent.java
@@ -46,12 +46,13 @@ public class ConfigurationChangedEvent {
     Map<String, Object> itemsModified = new HashMap<>();
     boolean changed = false;
 
-    for (String itemKey : latest.keySet()) {
+    for (Map.Entry<String, Object> entry : latest.entrySet()) {
+      String itemKey = entry.getKey();
       if (!last.containsKey(itemKey)) {
-        itemsCreated.put(itemKey, latest.get(itemKey));
+        itemsCreated.put(itemKey, entry.getValue());
         changed = true;
       } else if (!Objects.equals(last.get(itemKey), latest.get(itemKey))) {
-        itemsModified.put(itemKey, latest.get(itemKey));
+        itemsModified.put(itemKey, entry.getValue());
         changed = true;
       }
     }
diff --git a/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/ConfigUtil.java b/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/ConfigUtil.java
index 88c49859d..d0e7730ff 100644
--- a/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/ConfigUtil.java
+++ b/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/ConfigUtil.java
@@ -291,10 +291,11 @@ public final class ConfigUtil {
     public void updateConfiguration(WatchedUpdateResult watchedUpdateResult) {
       Map<String, Object> adds = watchedUpdateResult.getAdded();
       if (adds != null) {
-        for (String add : adds.keySet()) {
+        for (Map.Entry<String, Object> entry : adds.entrySet()) {
+          String add = entry.getKey();
           if (add.startsWith(CONFIG_CSE_PREFIX)) {
             String key = CONFIG_SERVICECOMB_PREFIX + add.substring(add.indexOf(".") + 1);
-            injectConfig.addProperty(key, adds.get(add));
+            injectConfig.addProperty(key, entry.getValue());
           }
         }
       }
@@ -310,10 +311,11 @@ public final class ConfigUtil {
 
       Map<String, Object> changes = watchedUpdateResult.getChanged();
       if (changes != null) {
-        for (String change : changes.keySet()) {
+        for (Map.Entry<String, Object> entry : changes.entrySet()) {
+          String change = entry.getKey();
           if (change.startsWith(CONFIG_CSE_PREFIX)) {
             String key = CONFIG_SERVICECOMB_PREFIX + change.substring(change.indexOf(".") + 1);
-            injectConfig.setProperty(key, changes.get(change));
+            injectConfig.setProperty(key, entry.getValue());
           }
         }
       }