wuqingjun opened a new pull request, #24431: URL: https://github.com/apache/kafka/pull/24431
`ExpiringCredentialRefreshingLogin` waited the entire interval until the next re-login in a single `time.sleep(nextRefreshMs - nowMs)`. `Thread.sleep` uses a relative, monotonic-clock timeout that does not advance while the host is suspended (laptop sleep or a paused/live-migrated VM), so if the host is suspended during that sleep the credential can expire (wall-clock) long before the re-login runs — the client then presents an expired token and authentication fails until the original sleep elapses. Observed in a multi-day soak test: after a ~4-hour laptop suspend, SASL/OAUTHBEARER workloads kept failing with `invalid_token` even though fresh tokens were available, and did not recover until the thread's sleep elapsed (or the client was restarted). This waits in bounded chunks (`MAX_SLEEP_CHUNK_MS`, 60s), re-reading the wall clock after each chunk and re-logging in as soon as the deadline has passed, capping how late the re-login can be after a resume to one chunk. No public interface change. Out of scope: triggering an early refresh specifically on a failed re-authentication (a larger change). ### Tests Two new unit tests simulate a host suspend via a `MockTime` that jumps the clock mid-sleep (`sleepUntilWallClockReturnsPromptlyAfterHostSuspend`, `sleepUntilWallClockWaitsInBoundedChunksAndStopsAtTheDeadline`); the existing `testRefresh` is unaffected. `:clients:checkstyleMain`, `:clients:checkstyleTest`, and `ExpiringCredentialRefreshingLoginTest` pass locally. -- 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]
