diff --git a/clients/src/test/java/org/apache/kafka/test/TestUtils.java b/clients/src/test/java/org/apache/kafka/test/TestUtils.java index bac8a2bf593f8..d06641f50322e 100644 --- a/clients/src/test/java/org/apache/kafka/test/TestUtils.java +++ b/clients/src/test/java/org/apache/kafka/test/TestUtils.java @@ -316,7 +316,7 @@ public static void waitForCondition(final TestCondition testCondition, final lon */ public static void retryOnExceptionWithTimeout(final long timeoutMs, final ValuelessCallable runnable) throws InterruptedException { - retryOnExceptionWithTimeout(DEFAULT_POLL_INTERVAL_MS, timeoutMs, runnable); + retryOnExceptionWithTimeout(timeoutMs, DEFAULT_POLL_INTERVAL_MS, runnable); } /** @@ -328,7 +328,7 @@ public static void retryOnExceptionWithTimeout(final long timeoutMs, * @throws InterruptedException if the current thread is interrupted while waiting for {@code runnable} to complete successfully. */ public static void retryOnExceptionWithTimeout(final ValuelessCallable runnable) throws InterruptedException { - retryOnExceptionWithTimeout(DEFAULT_POLL_INTERVAL_MS, DEFAULT_MAX_WAIT_MS, runnable); + retryOnExceptionWithTimeout(DEFAULT_MAX_WAIT_MS, DEFAULT_POLL_INTERVAL_MS, runnable); } /** @@ -336,13 +336,13 @@ public static void retryOnExceptionWithTimeout(final ValuelessCallable runnable) * {@link AssertionError}s, or for the given timeout to expire. If the timeout expires then the * last exception or assertion failure will be thrown thus providing context for the failure. * - * @param pollIntervalMs the interval in milliseconds to wait between invoking {@code runnable}. * @param timeoutMs the total time in milliseconds to wait for {@code runnable} to complete successfully. + * @param pollIntervalMs the interval in milliseconds to wait between invoking {@code runnable}. * @param runnable the code to attempt to execute successfully. * @throws InterruptedException if the current thread is interrupted while waiting for {@code runnable} to complete successfully. */ - public static void retryOnExceptionWithTimeout(final long pollIntervalMs, - final long timeoutMs, + public static void retryOnExceptionWithTimeout(final long timeoutMs, + final long pollIntervalMs, final ValuelessCallable runnable) throws InterruptedException { final long expectedEnd = System.currentTimeMillis() + timeoutMs; diff --git a/metadata/src/test/java/org/apache/kafka/controller/QuorumControllerTestEnv.java b/metadata/src/test/java/org/apache/kafka/controller/QuorumControllerTestEnv.java index 99270422fcf2c..20030ab32ef8a 100644 --- a/metadata/src/test/java/org/apache/kafka/controller/QuorumControllerTestEnv.java +++ b/metadata/src/test/java/org/apache/kafka/controller/QuorumControllerTestEnv.java @@ -53,7 +53,7 @@ public QuorumControllerTestEnv(LocalLogManagerTestEnv logEnv, QuorumController activeController() throws InterruptedException { AtomicReference value = new AtomicReference<>(null); - TestUtils.retryOnExceptionWithTimeout(3, 20000, () -> { + TestUtils.retryOnExceptionWithTimeout(20000, 3, () -> { QuorumController activeController = null; for (QuorumController controller : controllers) { if (controller.isActive()) { diff --git a/metadata/src/test/java/org/apache/kafka/metalog/LocalLogManagerTest.java b/metadata/src/test/java/org/apache/kafka/metalog/LocalLogManagerTest.java index ac578fb635807..927004cd74723 100644 --- a/metadata/src/test/java/org/apache/kafka/metalog/LocalLogManagerTest.java +++ b/metadata/src/test/java/org/apache/kafka/metalog/LocalLogManagerTest.java @@ -92,7 +92,7 @@ public void testPassLeadership() throws Exception { private static void waitForLastCommittedOffset(long targetOffset, LocalLogManager logManager) throws InterruptedException { - TestUtils.retryOnExceptionWithTimeout(3, 20000, () -> { + TestUtils.retryOnExceptionWithTimeout(20000, 3, () -> { MockMetaLogManagerListener listener = (MockMetaLogManagerListener) logManager.listeners().get(0); long highestOffset = -1; diff --git a/metadata/src/test/java/org/apache/kafka/metalog/LocalLogManagerTestEnv.java b/metadata/src/test/java/org/apache/kafka/metalog/LocalLogManagerTestEnv.java index 52aeea052bdde..21e0fdbe0acda 100644 --- a/metadata/src/test/java/org/apache/kafka/metalog/LocalLogManagerTestEnv.java +++ b/metadata/src/test/java/org/apache/kafka/metalog/LocalLogManagerTestEnv.java @@ -102,7 +102,7 @@ File dir() { MetaLogLeader waitForLeader() throws InterruptedException { AtomicReference value = new AtomicReference<>(null); - TestUtils.retryOnExceptionWithTimeout(3, 20000, () -> { + TestUtils.retryOnExceptionWithTimeout(2000, 3, () -> { MetaLogLeader result = null; for (LocalLogManager logManager : logManagers) { MetaLogLeader leader = logManager.leader(); diff --git a/streams/src/test/java/org/apache/kafka/streams/integration/OptimizedKTableIntegrationTest.java b/streams/src/test/java/org/apache/kafka/streams/integration/OptimizedKTableIntegrationTest.java index cefb7123c3e68..933e7c374d912 100644 --- a/streams/src/test/java/org/apache/kafka/streams/integration/OptimizedKTableIntegrationTest.java +++ b/streams/src/test/java/org/apache/kafka/streams/integration/OptimizedKTableIntegrationTest.java @@ -134,7 +134,7 @@ public void shouldApplyUpdatesToStandbyStore() throws Exception { } final ReadOnlyKeyValueStore newActiveStore = kafkaStreams1WasFirstActive ? store2 : store1; - TestUtils.retryOnExceptionWithTimeout(100, 60 * 1000, () -> { + TestUtils.retryOnExceptionWithTimeout(60 * 1000, 100, () -> { // Assert that after failover we have recovered to the last store write assertThat(newActiveStore.get(key), is(equalTo(batch1NumMessages - 1))); }); @@ -146,7 +146,7 @@ public void shouldApplyUpdatesToStandbyStore() throws Exception { // Assert that all messages in the second batch were processed in a timely manner assertThat(semaphore.tryAcquire(batch2NumMessages, 60, TimeUnit.SECONDS), is(equalTo(true))); - TestUtils.retryOnExceptionWithTimeout(100, 60 * 1000, () -> { + TestUtils.retryOnExceptionWithTimeout(60 * 1000, 100, () -> { // Assert that the current value in store reflects all messages being processed assertThat(newActiveStore.get(key), is(equalTo(totalNumMessages - 1))); });