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

mikexue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/eventmesh.git


The following commit(s) were added to refs/heads/master by this push:
     new b33118deb [ISSUE #3481] Replace this "Map.containsKey()" with a call 
to "Map.computeIfAbsent()".
b33118deb is described below

commit b33118debb1573273b14aa6e97b2a655add98ce3
Author: gbhowmick1 <[email protected]>
AuthorDate: Mon Apr 24 13:59:24 2023 +0530

    [ISSUE #3481] Replace this "Map.containsKey()" with a call to 
"Map.computeIfAbsent()".
---
 .../java/org/apache/eventmesh/webhook/api/Manufacturer.java    | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git 
a/eventmesh-webhook/eventmesh-webhook-api/src/main/java/org/apache/eventmesh/webhook/api/Manufacturer.java
 
b/eventmesh-webhook/eventmesh-webhook-api/src/main/java/org/apache/eventmesh/webhook/api/Manufacturer.java
index 36be35dbf..53f175712 100644
--- 
a/eventmesh-webhook/eventmesh-webhook-api/src/main/java/org/apache/eventmesh/webhook/api/Manufacturer.java
+++ 
b/eventmesh-webhook/eventmesh-webhook-api/src/main/java/org/apache/eventmesh/webhook/api/Manufacturer.java
@@ -18,17 +18,17 @@
 package org.apache.eventmesh.webhook.api;
 
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
 
 public class Manufacturer {
 
     private Set<String> manufacturerSet = new HashSet<>();
 
-    private Map<String, List<String>> manufacturerEventMap = new HashMap<>();
+    private Map<String, List<String>> manufacturerEventMap = new 
ConcurrentHashMap<>();
 
 
     public Set<String> getManufacturerSet() {
@@ -54,11 +54,7 @@ public class Manufacturer {
     }
 
     public List<String> getManufacturerEvents(String manufacturerName) {
-        if (!manufacturerEventMap.containsKey(manufacturerName)) {
-            List<String> m = new ArrayList<>();
-            manufacturerEventMap.put(manufacturerName, m);
-            return m;
-        }
+        manufacturerEventMap.putIfAbsent(manufacturerName, new 
ArrayList<String>());
         return manufacturerEventMap.get(manufacturerName);
     }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to