Ridzzz0Alam opened a new pull request, #24399:
URL: https://github.com/apache/kafka/pull/24399
### The issue
Closing a client that uses OAUTHBEARER can hang forever in
`ExpiringCredentialRefreshingLogin#close`. It runs under the `LoginManager`
class lock so every other SASL client in the JVM then hangs on create or close.
### Why it happened
The `close()` method interrupts the refresh thread once and joins without a
timeout. The thread only checks the interrupt flag after it sleeps. A login
callback handler that clears the flag during a re-login (for example by
catching the `InterruptedException` and rethrowing it wrapped) therefore keeps
the thread refreshing forever.
### The fix
`close()` sets a volatile `closing` flag before the interrupt. The thread
checks it before and after each sleep so it exits whether or not it sees the
interrupt.
### Tests
New
`ExpiringCredentialRefreshingLoginTest#testCloseWhenReloginClearsInterrupt`
with a re-login that swallows the interrupt and then either returns or throws
`LoginException`. Both cases time out without the fix and pass with it.
### Not covered
`LoginManager#release` still calls `close()` under the class lock so a
handler that blocks forever in a re-login can still hang it. Moving the close
out of the lock is a separate change.
--
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]