kirktrue opened a new pull request, #12398:
URL: https://github.com/apache/kafka/pull/12398

   What
   ----
   Kafka client is adding and removing the SASL extensions alternatively at the 
time of token refresh. During the window when the extensions are not present in 
the subject. If a connection to a broker is reattempted, it fails with the 
error that the extensions are missing.
   
   Why
   ----
   In clients, a Subject object is maintained which contains two sets each for 
Private and Public Credentials. Public Credentials includes the extensions. 
These values are stored in a `SaslExtensions` object which internally maintains 
these in a HashMap. 
   
   At the time of token refresh, a SaslExtensions object with these extensions 
is added to the public credentials set. As a next step, the refresh thread 
tries to logout the client for the older credentials. So it tries to remove the 
older token (private credential) and older SaslExtensions object (public 
credential) from the sets maintained in the Subject object. 
   
   SaslExtensions Class overrides the `equals` and `hashcode` functions and 
directly calls the `equals` and `hashcode` functions of HashMap. So at the time 
refresh when a new SaslExtensions object is added, because the extension values 
don't change, it results in a no-op because the hashes of the existing 
SaslExtensions object and the new object will be equals. But in the logout 
step, the only SaslExtensions object present in the set gets removed.
   
   After removing the extensions in 1st refresh, the extensions will get added 
again at the time of 2nd refresh. So, this addition and removal keep happening 
alternatively.
   
   The addition and removal of private credentials (tokens) from Subject work 
just fine because the tokens are always different.
   
   ### 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.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

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

Reply via email to