You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@eventmesh.apache.org by "erzohrakhan (via GitHub)" <gi...@apache.org> on 2023/03/21 20:03:48 UTC

[GitHub] [incubator-eventmesh] erzohrakhan opened a new pull request, #3499: Fixes #3481

erzohrakhan opened a new pull request, #3499:
URL: https://github.com/apache/incubator-eventmesh/pull/3499

   
   Fixes #3481 
   
   ### Motivation
   Use java.util.Map.computeIfAbsent() method instead of java.util.Map.containsKey()(for adding and changing values in the map). This leads to cleaner and more readable code.
   
   
   ### Modifications
   Replaced map.containsKey() with map.computeIfAbsent() method
   
   ### Documentation
   
   - Does this pull request introduces a new feature? (yes/no) no
   


-- 
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: dev-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org


[GitHub] [incubator-eventmesh] codecov[bot] commented on pull request #3499: [ISSUE #3481] Replace this "Map.containsKey()" with a call to "Map.computeIfAbsent()".

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #3499:
URL: https://github.com/apache/incubator-eventmesh/pull/3499#issuecomment-1478841794

   ## [Codecov](https://codecov.io/gh/apache/incubator-eventmesh/pull/3499?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#3499](https://codecov.io/gh/apache/incubator-eventmesh/pull/3499?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (36ae51d) into [master](https://codecov.io/gh/apache/incubator-eventmesh/commit/07bec46e83c4ad7b61fb6d7156ac32d229dd3edb?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (07bec46) will **decrease** coverage by `0.02%`.
   > The diff coverage is `n/a`.
   
   > :exclamation: Current head 36ae51d differs from pull request most recent head 147be76. Consider uploading reports for the commit 147be76 to get more accurate results
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #3499      +/-   ##
   ============================================
   - Coverage     14.63%   14.61%   -0.02%     
     Complexity     1526     1526              
   ============================================
     Files           651      651              
     Lines         31711    31702       -9     
     Branches       3033     3019      -14     
   ============================================
   - Hits           4640     4633       -7     
     Misses        26655    26655              
   + Partials        416      414       -2     
   ```
   
   
   [see 7 files with indirect coverage changes](https://codecov.io/gh/apache/incubator-eventmesh/pull/3499/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #3481] Replace this "Map.containsKey()" with a call to "Map.computeIfAbsent()". (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on PR #3499:
URL: https://github.com/apache/eventmesh/pull/3499#issuecomment-1818110022

   > @erzohrakhan As this PR has not been updated for some time, the issue related to this Pull Request has already been resolved. It is suggested to have this PR closed. Thanks for your contribution.
   
   


-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


[GitHub] [incubator-eventmesh] mytang0 commented on a diff in pull request #3499: [ISSUE #3481] Replace this "Map.containsKey()" with a call to "Map.computeIfAbsent()".

Posted by "mytang0 (via GitHub)" <gi...@apache.org>.
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #3481] Replace this "Map.containsKey()" with a call to "Map.computeIfAbsent()". (eventmesh)

Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on PR #3499:
URL: https://github.com/apache/eventmesh/pull/3499#issuecomment-1627324866

   @erzohrakhan As this PR has not been updated for some time, the issue related to this Pull Request has already been resolved. It is suggested to have this PR closed. Thanks for your contribution.


-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE #3481] Replace this "Map.containsKey()" with a call to "Map.computeIfAbsent()". (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo closed pull request #3499: [ISSUE #3481] Replace this "Map.containsKey()" with a call to "Map.computeIfAbsent()".
URL: https://github.com/apache/eventmesh/pull/3499


-- 
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: dev-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org