You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by GitBox <gi...@apache.org> on 2021/10/03 02:50:09 UTC

[GitHub] [incubator-shenyu] Jiaming1999 opened a new pull request #2189: thread safe fix

Jiaming1999 opened a new pull request #2189:
URL: https://github.com/apache/incubator-shenyu/pull/2189


   My PR is about fixing thread-safety about ConcurrentHashMap usage.
   The reports are automatically generated by Amazon AWS CodeGuru Reviewer.
   The problem:
   Usage of containsKey() and put() may not be thread-safe at lines: 54 and 59. Two threads can perform this same check at the same time and one thread can overwrite the value written by the other thread.
   My potential solution:
   Using putIfAbsent() to replace put(), by the logic of original code, the put should not be called again to update the existing key, so using putIfAbsent will automatically stop the operation if any thread put things first.
   
   
   


-- 
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: notifications-unsubscribe@shenyu.apache.org

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



[GitHub] [incubator-shenyu] tydhot merged pull request #2189: thread safe fix

Posted by GitBox <gi...@apache.org>.
tydhot merged pull request #2189:
URL: https://github.com/apache/incubator-shenyu/pull/2189


   


-- 
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: notifications-unsubscribe@shenyu.apache.org

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