mytang0 commented on code in PR #3499:
URL:
https://github.com/apache/incubator-eventmesh/pull/3499#discussion_r1145587175
##########
eventmesh-webhook/eventmesh-webhook-api/src/main/java/org/apache/eventmesh/webhook/api/Manufacturer.java:
##########
@@ -54,11 +54,7 @@ public void setManufacturerEventMap(Map<String,
List<String>> manufacturerEventM
}
public List<String> getManufacturerEvents(String manufacturerName) {
- if (!manufacturerEventMap.containsKey(manufacturerName)) {
- List<String> m = new ArrayList<>();
- manufacturerEventMap.put(manufacturerName, m);
- return m;
- }
+ manufacturerEventMap.computeIfAbsent(manufacturerName, key ->
manufacturerEventMap.put(manufacturerName, new ArrayList<>()));
Review Comment:
1. It is recommended to use ConcurrentHashMap
2. The logic can be further simplified
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]