You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2020/10/28 08:32:21 UTC

[GitHub] [kafka] chia7712 opened a new pull request #9517: MINOR: add comments to explain why it needs to add synchronization on…

chia7712 opened a new pull request #9517:
URL: https://github.com/apache/kafka/pull/9517


   The reason of adding synchronization is obscure so it looks like a bug. It seems to me we should add comment to make it more readable.
   
   ### Committer Checklist (excluded from commit message)
   - [ ] Verify design and implementation 
   - [ ] Verify test coverage and CI build status
   - [ ] Verify documentation (including upgrade notes)
   


----------------------------------------------------------------
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.

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



[GitHub] [kafka] chia7712 commented on a change in pull request #9517: MINOR: add comments to explain why it needs to add synchronization on…

Posted by GitBox <gi...@apache.org>.
chia7712 commented on a change in pull request #9517:
URL: https://github.com/apache/kafka/pull/9517#discussion_r539420751



##########
File path: clients/src/main/java/org/apache/kafka/common/security/authenticator/SaslClientAuthenticator.java
##########
@@ -612,6 +612,9 @@ private void handleSaslHandshakeResponse(SaslHandshakeResponse response) {
      */
     public static String firstPrincipal(Subject subject) {
         Set<Principal> principals = subject.getPrincipals();
+        // getPrincipals() returns a SynchronizedSet and iteration over SynchronizedSet is not thread safe.
+        // Hence, we have to add synchronization on local variable "principals".
+        // see https://github.com/apache/kafka/pull/3208#discussion_r120130706 for discussion.

Review comment:
       fair enough. I will remove the link to older discussion. the remaining comment should be enough.




----------------------------------------------------------------
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.

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



[GitHub] [kafka] ijuma commented on a change in pull request #9517: MINOR: add comments to explain why it needs to add synchronization on…

Posted by GitBox <gi...@apache.org>.
ijuma commented on a change in pull request #9517:
URL: https://github.com/apache/kafka/pull/9517#discussion_r539415671



##########
File path: clients/src/main/java/org/apache/kafka/common/security/authenticator/SaslClientAuthenticator.java
##########
@@ -612,6 +612,9 @@ private void handleSaslHandshakeResponse(SaslHandshakeResponse response) {
      */
     public static String firstPrincipal(Subject subject) {
         Set<Principal> principals = subject.getPrincipals();
+        // getPrincipals() returns a SynchronizedSet and iteration over SynchronizedSet is not thread safe.
+        // Hence, we have to add synchronization on local variable "principals".
+        // see https://github.com/apache/kafka/pull/3208#discussion_r120130706 for discussion.

Review comment:
       Instead of referencing an older discussion, I would make sure the comment is self contained.




----------------------------------------------------------------
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.

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