splett2 commented on code in PR #14888:
URL: https://github.com/apache/kafka/pull/14888#discussion_r1411492950
##########
clients/src/test/java/org/apache/kafka/common/security/oauthbearer/internals/secured/RefreshingHttpsJwksTest.java:
##########
@@ -62,14 +62,14 @@ public class RefreshingHttpsJwksTest extends
OAuthBearerTest {
@Test
public void testBasicScheduleRefresh() throws Exception {
String keyId = "abc123";
- Time time = new MockTime();
+ MockTime time = new MockTime();
HttpsJwks httpsJwks = spyHttpsJwks();
- try (RefreshingHttpsJwks refreshingHttpsJwks =
getRefreshingHttpsJwks(time, httpsJwks)) {
+ try (RefreshingHttpsJwks refreshingHttpsJwks =
getRefreshingHttpsJwks(time, httpsJwks, mockExecutorService(time))) {
refreshingHttpsJwks.init();
verify(httpsJwks, times(1)).refresh();
assertTrue(refreshingHttpsJwks.maybeExpediteRefresh(keyId));
- verify(httpsJwks, times(1)).refresh();
+ verify(httpsJwks, times(2)).refresh();
Review Comment:
This assertion was incorrect, mockito expects us to pass through the total
number of times the invocation has been called.
We expect to call refresh once in `init()` and again when calling
`maybeExpediteRefresh`. Since `maybeExpediteRefresh` was scheduling the refresh
in a background thread, the test thread would usually win the race. We can
deterministically induce a failure, by calling `Thread.sleep(100)` in the test
thread.
--
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]