From 371235a19ca6a0da73cf6cfc291199d8b400b8be Mon Sep 17 00:00:00 2001 From: yash Date: Thu, 30 Nov 2023 23:29:25 +0530 Subject: [PATCH] [ISSUE 4622] Checkstyle configured --- .../org/apache/rocketmq/broker/BrokerControllerTest.java | 3 +-- .../org/apache/rocketmq/broker/BrokerOuterAPITest.java | 4 ++-- .../rocketmq/broker/controller/ReplicasManagerTest.java | 4 ++-- .../broker/filter/MessageStoreWithFilterTest.java | 4 ++-- .../rocketmq/broker/latency/BrokerFastFailureTest.java | 3 +-- .../broker/processor/PopBufferMergeServiceTest.java | 2 +- .../broker/schedule/ScheduleMessageServiceTest.java | 3 +-- .../client/consumer/DefaultLitePullConsumerTest.java | 4 ++-- .../client/consumer/DefaultMQPushConsumerTest.java | 2 +- .../rebalance/AllocateMessageQueueConsitentHashTest.java | 2 +- .../consumer/ConsumeMessageConcurrentlyServiceTest.java | 2 +- .../rocketmq/client/producer/DefaultMQProducerTest.java | 2 +- .../apache/rocketmq/common/stats/StatsItemSetTest.java | 6 +++--- .../rocketmq/controller/impl/DLedgerControllerTest.java | 2 +- .../java/org/apache/rocketmq/filter/BitsArrayTest.java | 2 +- .../processor/ClusterTestRequestProcessorTest.java | 3 +-- .../service/route/ClusterTopicRouteServiceTest.java | 2 +- .../org/apache/rocketmq/test/util/MQAdminTestUtils.java | 4 ++-- .../java/org/apache/rocketmq/test/util/TestUtil.java | 8 ++++---- .../java/org/apache/rocketmq/test/util/TestUtils.java | 9 ++++----- .../rocketmq/tieredstore/index/IndexStoreFileTest.java | 2 +- .../tieredstore/index/IndexStoreServiceTest.java | 8 ++++---- .../tieredstore/provider/TieredFileSegmentTest.java | 5 ++--- 23 files changed, 40 insertions(+), 46 deletions(-) diff --git a/broker/src/test/java/org/apache/rocketmq/broker/BrokerControllerTest.java b/broker/src/test/java/org/apache/rocketmq/broker/BrokerControllerTest.java index eada122dc19..d3f7c8274b1 100644 --- a/broker/src/test/java/org/apache/rocketmq/broker/BrokerControllerTest.java +++ b/broker/src/test/java/org/apache/rocketmq/broker/BrokerControllerTest.java @@ -22,7 +22,6 @@ import java.util.UUID; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.TimeUnit; import org.apache.rocketmq.common.BrokerConfig; import org.apache.rocketmq.common.UtilAll; @@ -93,7 +92,7 @@ public void run() { queue.add(new FutureTaskExt<>(requestTask, null)); long headSlowTimeMills = 100; - Awaitility.await().pollDelay(Duration.ofMillis(headSlowTimeMills)).until(()->true); + Awaitility.await().pollDelay(Duration.ofMillis(headSlowTimeMills)).until(() -> true); assertThat(brokerController.headSlowTimeMills(queue)).isGreaterThanOrEqualTo(headSlowTimeMills); } } diff --git a/broker/src/test/java/org/apache/rocketmq/broker/BrokerOuterAPITest.java b/broker/src/test/java/org/apache/rocketmq/broker/BrokerOuterAPITest.java index b92e0bc14bc..eaaafecc0f2 100644 --- a/broker/src/test/java/org/apache/rocketmq/broker/BrokerOuterAPITest.java +++ b/broker/src/test/java/org/apache/rocketmq/broker/BrokerOuterAPITest.java @@ -27,7 +27,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; -import java.util.concurrent.TimeUnit; + import java.util.concurrent.atomic.AtomicBoolean; import org.apache.rocketmq.broker.out.BrokerOuterAPI; import org.apache.rocketmq.common.BrokerConfig; @@ -133,7 +133,7 @@ public RemotingCommand answer(InvocationOnMock invocation) throws Throwable { } else if (invocation.getArgument(0) == nameserver2) { return buildResponse(Boolean.FALSE); } else if (invocation.getArgument(0) == nameserver3) { - Awaitility.await().pollDelay(Duration.ofMillis(timeOut+20)).until(()->true); + Awaitility.await().pollDelay(Duration.ofMillis(timeOut + 20)).until(() -> true); return buildResponse(Boolean.TRUE); } return buildResponse(Boolean.TRUE); diff --git a/broker/src/test/java/org/apache/rocketmq/broker/controller/ReplicasManagerTest.java b/broker/src/test/java/org/apache/rocketmq/broker/controller/ReplicasManagerTest.java index 65c70e93da4..171347da5cf 100644 --- a/broker/src/test/java/org/apache/rocketmq/broker/controller/ReplicasManagerTest.java +++ b/broker/src/test/java/org/apache/rocketmq/broker/controller/ReplicasManagerTest.java @@ -22,7 +22,7 @@ import java.util.Arrays; import java.util.HashSet; import java.util.UUID; -import java.util.concurrent.TimeUnit; + import org.apache.rocketmq.broker.BrokerController; import org.apache.rocketmq.broker.out.BrokerOuterAPI; @@ -173,7 +173,7 @@ public void before() throws Exception { autoSwitchHAService.init(defaultMessageStore); replicasManager.start(); // execute schedulingSyncBrokerMetadata() - Awaitility.await().pollDelay(Duration.ofSeconds(SCHEDULE_SERVICE_EXEC_PERIOD)).until(()->true); + Awaitility.await().pollDelay(Duration.ofSeconds(SCHEDULE_SERVICE_EXEC_PERIOD)).until(() -> true); } @After diff --git a/broker/src/test/java/org/apache/rocketmq/broker/filter/MessageStoreWithFilterTest.java b/broker/src/test/java/org/apache/rocketmq/broker/filter/MessageStoreWithFilterTest.java index 25e4f3771f9..5c190a6605a 100644 --- a/broker/src/test/java/org/apache/rocketmq/broker/filter/MessageStoreWithFilterTest.java +++ b/broker/src/test/java/org/apache/rocketmq/broker/filter/MessageStoreWithFilterTest.java @@ -236,7 +236,7 @@ protected List filtered(List msgs, public void testGetMessage_withFilterBitMapAndConsumerChanged() throws Exception { List msgs = putMsg(master, topicCount, msgPerTopic); - Awaitility.await().pollDelay(Duration.ofMillis(200)).until(()->true); + Awaitility.await().pollDelay(Duration.ofMillis(200)).until(() -> true); // reset consumer; @@ -299,7 +299,7 @@ public void testGetMessage_withFilterBitMapAndConsumerChanged() throws Exception public void testGetMessage_withFilterBitMap() throws Exception { List msgs = putMsg(master, topicCount, msgPerTopic); - Awaitility.await().pollDelay(Duration.ofMillis(200)).until(()->true); + Awaitility.await().pollDelay(Duration.ofMillis(200)).until(() -> true); for (int i = 0; i < topicCount; i++) { String realTopic = TOPIC + i; diff --git a/broker/src/test/java/org/apache/rocketmq/broker/latency/BrokerFastFailureTest.java b/broker/src/test/java/org/apache/rocketmq/broker/latency/BrokerFastFailureTest.java index bb98aa99d44..0325d5314dd 100644 --- a/broker/src/test/java/org/apache/rocketmq/broker/latency/BrokerFastFailureTest.java +++ b/broker/src/test/java/org/apache/rocketmq/broker/latency/BrokerFastFailureTest.java @@ -19,7 +19,6 @@ import java.time.Duration; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.TimeUnit; import org.apache.rocketmq.common.future.FutureTaskExt; import org.apache.rocketmq.remoting.netty.RequestTask; import org.awaitility.Awaitility; @@ -55,7 +54,7 @@ public void run() { RequestTask expiredRequest = new RequestTask(runnable, null, null); queue.add(new FutureTaskExt<>(expiredRequest, null)); - Awaitility.await().pollDelay(Duration.ofMillis(100)).until(()->true); + Awaitility.await().pollDelay(Duration.ofMillis(100)).until(() -> true); RequestTask requestTask = new RequestTask(runnable, null, null); queue.add(new FutureTaskExt<>(requestTask, null)); diff --git a/broker/src/test/java/org/apache/rocketmq/broker/processor/PopBufferMergeServiceTest.java b/broker/src/test/java/org/apache/rocketmq/broker/processor/PopBufferMergeServiceTest.java index 83a1fc1eb7b..e10974281a7 100644 --- a/broker/src/test/java/org/apache/rocketmq/broker/processor/PopBufferMergeServiceTest.java +++ b/broker/src/test/java/org/apache/rocketmq/broker/processor/PopBufferMergeServiceTest.java @@ -118,7 +118,7 @@ public void testBasic() throws Exception { try { assertThat(popBufferMergeService.addCk(ck, reviveQid, ackOffset, nextBeginOffset)).isTrue(); assertThat(popBufferMergeService.getLatestOffset(topic, group, queueId)).isEqualTo(nextBeginOffset); - Awaitility.await().pollDelay(Duration.ofMillis(1000)).until(()->true); // wait background threads of PopBufferMergeService run for some time + Awaitility.await().pollDelay(Duration.ofMillis(1000)).until(() -> true); // wait background threads of PopBufferMergeService run for some time assertThat(popBufferMergeService.addAk(reviveQid, ackMsg)).isTrue(); assertThat(popBufferMergeService.getLatestOffset(topic, group, queueId)).isEqualTo(nextBeginOffset); } finally { diff --git a/broker/src/test/java/org/apache/rocketmq/broker/schedule/ScheduleMessageServiceTest.java b/broker/src/test/java/org/apache/rocketmq/broker/schedule/ScheduleMessageServiceTest.java index f1e91a57a94..89d488287ad 100644 --- a/broker/src/test/java/org/apache/rocketmq/broker/schedule/ScheduleMessageServiceTest.java +++ b/broker/src/test/java/org/apache/rocketmq/broker/schedule/ScheduleMessageServiceTest.java @@ -32,7 +32,6 @@ import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.TimeUnit; import org.apache.rocketmq.broker.BrokerController; import org.apache.rocketmq.broker.failover.EscapeBridge; import org.apache.rocketmq.broker.util.HookUtils; @@ -220,7 +219,7 @@ public void testDeliverDelayedMessageTimerTask() throws Exception { // timer run maybe delay, then consumer message again // and wait offsetTable - Awaitility.await().pollDelay(Duration.ofSeconds(15)).until(()->true); + Awaitility.await().pollDelay(Duration.ofSeconds(15)).until(() -> true); scheduleMessageService.buildRunningStats(new HashMap<>()); messageResult = getMessage(realQueueId, offset); diff --git a/client/src/test/java/org/apache/rocketmq/client/consumer/DefaultLitePullConsumerTest.java b/client/src/test/java/org/apache/rocketmq/client/consumer/DefaultLitePullConsumerTest.java index 4c61593924f..6aff4d97ab5 100644 --- a/client/src/test/java/org/apache/rocketmq/client/consumer/DefaultLitePullConsumerTest.java +++ b/client/src/test/java/org/apache/rocketmq/client/consumer/DefaultLitePullConsumerTest.java @@ -481,7 +481,7 @@ public void onChanged(String topic, Set messageQueues) { Set set = new HashSet<>(); set.add(createMessageQueue()); doReturn(set).when(mQAdminImpl).fetchSubscribeMessageQueues(anyString()); - Awaitility.await().pollDelay(Duration.ofMillis(11*1000)).until(()->true); + Awaitility.await().pollDelay(Duration.ofMillis(11 * 1000)).until(() -> true); assertThat(flag).isTrue(); } finally { litePullConsumer.shutdown(); @@ -645,7 +645,7 @@ public void testConsumerAfterShutdown() throws Exception { new AsyncConsumer().executeAsync(defaultLitePullConsumer); - Awaitility.await().pollDelay(Duration.ofMillis(100)).until(()->true); + Awaitility.await().pollDelay(Duration.ofMillis(100)).until(() -> true); defaultLitePullConsumer.shutdown(); assertThat(defaultLitePullConsumer.isRunning()).isFalse(); } diff --git a/client/src/test/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumerTest.java b/client/src/test/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumerTest.java index b626f223d8e..258f35c318d 100644 --- a/client/src/test/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumerTest.java +++ b/client/src/test/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumerTest.java @@ -314,7 +314,7 @@ public ConsumeConcurrentlyStatus consumeMessage(List msgs, assertThat(msgs.get(0).getBody()).isEqualTo(msgBody); countDownLatch.countDown(); try { - Awaitility.await().pollDelay(Duration.ofMillis(1000)).until(()->true); + Awaitility.await().pollDelay(Duration.ofMillis(1000)).until(() -> true); messageConsumedFlag.set(true); } catch (Exception e) { } diff --git a/client/src/test/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueConsitentHashTest.java b/client/src/test/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueConsitentHashTest.java index 7c38abbf95a..b63918fdf7a 100644 --- a/client/src/test/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueConsitentHashTest.java +++ b/client/src/test/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueConsitentHashTest.java @@ -87,7 +87,7 @@ public void testRun100RandomCase() { int queueSize = new Random().nextInt(20) + 1;//1-20 testAllocate(queueSize, consumerSize); try { - Awaitility.await().pollDelay(Duration.ofMillis(1)).until(()->true); + Awaitility.await().pollDelay(Duration.ofMillis(1)).until(() -> true); } catch (Exception e) { } } diff --git a/client/src/test/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageConcurrentlyServiceTest.java b/client/src/test/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageConcurrentlyServiceTest.java index 9304473d36d..0f3ad7e221b 100644 --- a/client/src/test/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageConcurrentlyServiceTest.java +++ b/client/src/test/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageConcurrentlyServiceTest.java @@ -183,7 +183,7 @@ public ConsumeConcurrentlyStatus consumeMessage(List msgs, pullMessageService.executePullRequestImmediately(createPullRequest()); countDownLatch.await(); - Awaitility.await().pollDelay(Duration.ofMillis(1000)).until(()->true); + Awaitility.await().pollDelay(Duration.ofMillis(1000)).until(() -> true); ConsumeStatus stats = normalServie.getConsumerStatsManager().consumeStatus(pushConsumer.getDefaultMQPushConsumerImpl().groupName(),topic); diff --git a/client/src/test/java/org/apache/rocketmq/client/producer/DefaultMQProducerTest.java b/client/src/test/java/org/apache/rocketmq/client/producer/DefaultMQProducerTest.java index 0f357edf20c..aab080184e6 100644 --- a/client/src/test/java/org/apache/rocketmq/client/producer/DefaultMQProducerTest.java +++ b/client/src/test/java/org/apache/rocketmq/client/producer/DefaultMQProducerTest.java @@ -409,7 +409,7 @@ public void run() { assertThat(responseMap).isNotNull(); while (!finish.get()) { try { - Awaitility.await().pollDelay(Duration.ofMillis(10)).until(()->true); + Awaitility.await().pollDelay(Duration.ofMillis(10)).until(() -> true); } catch (ConditionTimeoutException e) { } MessageExt responseMsg = new MessageExt(); diff --git a/common/src/test/java/org/apache/rocketmq/common/stats/StatsItemSetTest.java b/common/src/test/java/org/apache/rocketmq/common/stats/StatsItemSetTest.java index f996f410ee9..6d067f593d5 100644 --- a/common/src/test/java/org/apache/rocketmq/common/stats/StatsItemSetTest.java +++ b/common/src/test/java/org/apache/rocketmq/common/stats/StatsItemSetTest.java @@ -68,7 +68,7 @@ public void run() { if (executor.getCompletedTaskCount() == 10) { break; } - Awaitility.await().pollDelay(Duration.ofMillis(1000)).until(()->true); + Awaitility.await().pollDelay(Duration.ofMillis(1000)).until(() -> true); } // simulate schedule task execution , tps stat { @@ -115,7 +115,7 @@ public void run() { if (executor.getCompletedTaskCount() == 10) { break; } - Awaitility.await().pollDelay(Duration.ofMillis(1000)).until(()->true); + Awaitility.await().pollDelay(Duration.ofMillis(1000)).until(() -> true); } return statsItemSet.getStatsItem("topicTest").getValue(); } @@ -136,7 +136,7 @@ public void run() { if (executor.getCompletedTaskCount() == 10) { break; } - Awaitility.await().pollDelay(Duration.ofMillis(1000)).until(()->true); + Awaitility.await().pollDelay(Duration.ofMillis(1000)).until(() -> true); } return statsItemSet.getAndCreateStatsItem("test").getValue(); } diff --git a/controller/src/test/java/org/apache/rocketmq/controller/impl/DLedgerControllerTest.java b/controller/src/test/java/org/apache/rocketmq/controller/impl/DLedgerControllerTest.java index 538fa51b772..f490b123397 100644 --- a/controller/src/test/java/org/apache/rocketmq/controller/impl/DLedgerControllerTest.java +++ b/controller/src/test/java/org/apache/rocketmq/controller/impl/DLedgerControllerTest.java @@ -292,7 +292,7 @@ public void testBrokerLifecycleListener() throws Exception { assertEquals(DEFAULT_BROKER_NAME, brokerName); atomicBoolean.set(true); }); - Awaitility.await().pollDelay(Duration.ofMillis(2000)).until(()->true); + Awaitility.await().pollDelay(Duration.ofMillis(2000)).until(() -> true); assertTrue(atomicBoolean.get()); } diff --git a/filter/src/test/java/org/apache/rocketmq/filter/BitsArrayTest.java b/filter/src/test/java/org/apache/rocketmq/filter/BitsArrayTest.java index 75e1fe6e552..4014cbe1ddf 100644 --- a/filter/src/test/java/org/apache/rocketmq/filter/BitsArrayTest.java +++ b/filter/src/test/java/org/apache/rocketmq/filter/BitsArrayTest.java @@ -35,7 +35,7 @@ BitsArray gen(int bitCount) { for (int i = 0; i < bitCount / Byte.SIZE; i++) { bitsArray.setByte(i, (byte) (new Random(System.currentTimeMillis())).nextInt(0xff)); try { - Awaitility.await().pollDelay(Duration.ofMillis(2)).until(()->true); + Awaitility.await().pollDelay(Duration.ofMillis(2)).until(() -> true); } catch (ConditionTimeoutException e) { } } diff --git a/namesrv/src/test/java/org/apache/rocketmq/namesrv/processor/ClusterTestRequestProcessorTest.java b/namesrv/src/test/java/org/apache/rocketmq/namesrv/processor/ClusterTestRequestProcessorTest.java index f2459327f4f..3740b0e8aae 100644 --- a/namesrv/src/test/java/org/apache/rocketmq/namesrv/processor/ClusterTestRequestProcessorTest.java +++ b/namesrv/src/test/java/org/apache/rocketmq/namesrv/processor/ClusterTestRequestProcessorTest.java @@ -23,7 +23,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.concurrent.TimeUnit; import org.apache.rocketmq.client.ClientConfig; import org.apache.rocketmq.client.exception.MQClientException; import org.apache.rocketmq.client.impl.MQClientAPIImpl; @@ -169,7 +168,7 @@ public void testNamesrv() throws Exception { RemotingCommand response = clientRequestProcessor.processRequest(mock(ChannelHandlerContext.class), remotingCommand); assertThat(response.getCode()).isEqualTo(ResponseCode.SYSTEM_ERROR); - Awaitility.await().pollDelay(Duration.ofSeconds(waitSecondsForService+1)).until(()->true); + Awaitility.await().pollDelay(Duration.ofSeconds(waitSecondsForService + 1)).until(() -> true); response = clientRequestProcessor.processRequest(mock(ChannelHandlerContext.class), remotingCommand); assertThat(response.getCode()).isEqualTo(ResponseCode.SUCCESS); } diff --git a/proxy/src/test/java/org/apache/rocketmq/proxy/service/route/ClusterTopicRouteServiceTest.java b/proxy/src/test/java/org/apache/rocketmq/proxy/service/route/ClusterTopicRouteServiceTest.java index f0113ad9be5..0ab4fbe4259 100644 --- a/proxy/src/test/java/org/apache/rocketmq/proxy/service/route/ClusterTopicRouteServiceTest.java +++ b/proxy/src/test/java/org/apache/rocketmq/proxy/service/route/ClusterTopicRouteServiceTest.java @@ -163,7 +163,7 @@ public void testTopicRouteCaffeineCache() throws InterruptedException { } }); assertThat(value).isEqualTo(topicCache.get(key)); - Awaitility.await().pollDelay(Duration.ofSeconds(5)).until(()->true); + Awaitility.await().pollDelay(Duration.ofSeconds(5)).until(() -> true); assertThat(value).isEqualTo(topicCache.get(key)); } } diff --git a/test/src/main/java/org/apache/rocketmq/test/util/MQAdminTestUtils.java b/test/src/main/java/org/apache/rocketmq/test/util/MQAdminTestUtils.java index 9f63bd3e9b7..c3daa43757e 100644 --- a/test/src/main/java/org/apache/rocketmq/test/util/MQAdminTestUtils.java +++ b/test/src/main/java/org/apache/rocketmq/test/util/MQAdminTestUtils.java @@ -123,7 +123,7 @@ public static boolean createSub(String nameSrvAddr, String clusterName, String c addr)); } catch (Exception e) { e.printStackTrace(); - Awaitility.await().pollDelay(Duration.ofMillis(1000*1)).until(()->true); + Awaitility.await().pollDelay(Duration.ofMillis(1000 * 1)).until(() -> true); } } } catch (Exception e) { @@ -173,7 +173,7 @@ public static boolean awaitStaticTopicMs(long timeMs, String topic, DefaultMQAdm if (checkStaticTopic(topic, defaultMQAdminExt, clientInstance)) { return true; } - Awaitility.await().pollDelay(Duration.ofMillis(100)).until(()->true); + Awaitility.await().pollDelay(Duration.ofMillis(100)).until(() -> true); } return false; } diff --git a/test/src/main/java/org/apache/rocketmq/test/util/TestUtil.java b/test/src/main/java/org/apache/rocketmq/test/util/TestUtil.java index c80b71fc0a8..c76c75d5942 100644 --- a/test/src/main/java/org/apache/rocketmq/test/util/TestUtil.java +++ b/test/src/main/java/org/apache/rocketmq/test/util/TestUtil.java @@ -24,7 +24,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.concurrent.TimeUnit; + import org.awaitility.Awaitility; import org.awaitility.core.ConditionTimeoutException; @@ -62,7 +62,7 @@ public static String addQuoteToParamater(String param) { public static void waitForMonment(long time) { try { - Awaitility.await().pollDelay(Duration.ofMillis(time)).until(()->true); + Awaitility.await().pollDelay(Duration.ofMillis(time)).until(() -> true); } catch (ConditionTimeoutException e) { e.printStackTrace(); } @@ -70,7 +70,7 @@ public static void waitForMonment(long time) { public static void waitForSeconds(long time) { try { - Awaitility.await().pollDelay(Duration.ofSeconds(time)).until(()->true); + Awaitility.await().pollDelay(Duration.ofSeconds(time)).until(() -> true); } catch (ConditionTimeoutException e) { e.printStackTrace(); } @@ -78,7 +78,7 @@ public static void waitForSeconds(long time) { public static void waitForMinutes(long time) { try { - Awaitility.await().pollDelay(Duration.ofMinutes(time)).until(()->true); + Awaitility.await().pollDelay(Duration.ofMinutes(time)).until(() -> true); } catch (ConditionTimeoutException e) { e.printStackTrace(); } diff --git a/test/src/main/java/org/apache/rocketmq/test/util/TestUtils.java b/test/src/main/java/org/apache/rocketmq/test/util/TestUtils.java index 0847af9ae84..6ff765a6cf7 100644 --- a/test/src/main/java/org/apache/rocketmq/test/util/TestUtils.java +++ b/test/src/main/java/org/apache/rocketmq/test/util/TestUtils.java @@ -18,17 +18,16 @@ package org.apache.rocketmq.test.util; import java.time.Duration; -import java.util.concurrent.TimeUnit; + import org.awaitility.Awaitility; import org.awaitility.core.ConditionTimeoutException; -import io.opentelemetry.sdk.metrics.internal.state.DebugUtils; public class TestUtils { public static void waitForMoment(long time) { try { - Awaitility.await().pollDelay(Duration.ofMillis(time)).until(()->true); + Awaitility.await().pollDelay(Duration.ofMillis(time)).until(() -> true); } catch (ConditionTimeoutException var3) { var3.printStackTrace(); } @@ -37,7 +36,7 @@ public static void waitForMoment(long time) { public static void waitForSeconds(long time) { try { - Awaitility.await().pollDelay(Duration.ofMillis(time)).until(()->true); + Awaitility.await().pollDelay(Duration.ofMillis(time)).until(() -> true); } catch (ConditionTimeoutException var3) { var3.printStackTrace(); } @@ -46,7 +45,7 @@ public static void waitForSeconds(long time) { public static void waitForMinutes(long time) { try { - Awaitility.await().pollDelay(Duration.ofMillis(time)).until(()->true); + Awaitility.await().pollDelay(Duration.ofMillis(time)).until(() -> true); } catch (ConditionTimeoutException var3) { var3.printStackTrace(); } diff --git a/tieredstore/src/test/java/org/apache/rocketmq/tieredstore/index/IndexStoreFileTest.java b/tieredstore/src/test/java/org/apache/rocketmq/tieredstore/index/IndexStoreFileTest.java index 94a14ebd7eb..50a6735eece 100644 --- a/tieredstore/src/test/java/org/apache/rocketmq/tieredstore/index/IndexStoreFileTest.java +++ b/tieredstore/src/test/java/org/apache/rocketmq/tieredstore/index/IndexStoreFileTest.java @@ -189,7 +189,7 @@ public void concurrentPutTest() throws InterruptedException { Assert.assertEquals(AppendResult.SUCCESS, indexStoreFile.putKey( TOPIC_NAME, TOPIC_ID, QUEUE_ID, KEY_SET, MESSAGE_OFFSET, MESSAGE_SIZE, timestamp)); try { - Awaitility.await().pollDelay(Duration.ofMillis(100)).until(()->true); + Awaitility.await().pollDelay(Duration.ofMillis(100)).until(() -> true); } catch (ConditionTimeoutException ignored) { } latch.countDown(); diff --git a/tieredstore/src/test/java/org/apache/rocketmq/tieredstore/index/IndexStoreServiceTest.java b/tieredstore/src/test/java/org/apache/rocketmq/tieredstore/index/IndexStoreServiceTest.java index 41d72c49eb3..71c28eb35df 100644 --- a/tieredstore/src/test/java/org/apache/rocketmq/tieredstore/index/IndexStoreServiceTest.java +++ b/tieredstore/src/test/java/org/apache/rocketmq/tieredstore/index/IndexStoreServiceTest.java @@ -99,7 +99,7 @@ public void basicServiceTest() throws InterruptedException { for (int i = 0; i < 50; i++) { Assert.assertEquals(AppendResult.SUCCESS, indexService.putKey( TOPIC_NAME, TOPIC_ID, QUEUE_ID, KEY_SET, i * 100, MESSAGE_SIZE, System.currentTimeMillis())); - Awaitility.await().pollDelay(Duration.ofMillis(1)).until(()->true); + Awaitility.await().pollDelay(Duration.ofMillis(1)).until(() -> true); } ConcurrentSkipListMap timeStoreTable = indexService.getTimeStoreTable(); Assert.assertEquals(3, timeStoreTable.size()); @@ -213,7 +213,7 @@ public void restartServiceTest() throws InterruptedException { TOPIC_NAME, TOPIC_ID, QUEUE_ID, Collections.singleton(String.valueOf(i)), i * 100L, MESSAGE_SIZE, System.currentTimeMillis()); Assert.assertEquals(AppendResult.SUCCESS, result); - Awaitility.await().pollDelay(Duration.ofMillis(1)).until(()->true); + Awaitility.await().pollDelay(Duration.ofMillis(1)).until(() -> true); } long timestamp = indexService.getTimeStoreTable().firstKey(); indexService.shutdown(); @@ -246,7 +246,7 @@ public void queryFromFileTest() throws InterruptedException, ExecutionException TOPIC_NAME, TOPIC_ID, QUEUE_ID, Collections.singleton(String.valueOf(j)), i * 100L + j, MESSAGE_SIZE, System.currentTimeMillis()); Assert.assertEquals(AppendResult.SUCCESS, result); - Awaitility.await().pollDelay(Duration.ofMillis(1)).until(()->true); + Awaitility.await().pollDelay(Duration.ofMillis(1)).until(() -> true); } } @@ -280,7 +280,7 @@ public void concurrentGetTest() throws InterruptedException { indexService.putKey(TOPIC_NAME, TOPIC_ID, j, Collections.singleton(String.valueOf(i)), i * 100L, i * 100, System.currentTimeMillis()); } - Awaitility.await().pollDelay(Duration.ofMillis(1)).until(()->true); + Awaitility.await().pollDelay(Duration.ofMillis(1)).until(() -> true); } CountDownLatch latch = new CountDownLatch(fileCount * 3); diff --git a/tieredstore/src/test/java/org/apache/rocketmq/tieredstore/provider/TieredFileSegmentTest.java b/tieredstore/src/test/java/org/apache/rocketmq/tieredstore/provider/TieredFileSegmentTest.java index db1eb7b543c..af55fa4828b 100644 --- a/tieredstore/src/test/java/org/apache/rocketmq/tieredstore/provider/TieredFileSegmentTest.java +++ b/tieredstore/src/test/java/org/apache/rocketmq/tieredstore/provider/TieredFileSegmentTest.java @@ -32,7 +32,6 @@ import org.junit.Assert; import org.junit.Test; -import io.opentelemetry.sdk.metrics.internal.state.DebugUtils; public class TieredFileSegmentTest { @@ -140,7 +139,7 @@ public void testCommitFailedThenSuccess() { segment.blocker = new CompletableFuture<>(); new Thread(() -> { try { - Awaitility.await().pollDelay(Duration.ofMillis(1000)).until(()->true); + Awaitility.await().pollDelay(Duration.ofMillis(1000)).until(() -> true); } catch (ConditionTimeoutException e) { Assert.fail(e.getMessage()); } @@ -196,7 +195,7 @@ public void testCommitFailed3Times() { segment.blocker = new CompletableFuture<>(); new Thread(() -> { try { - Awaitility.await().pollDelay(Duration.ofMillis(3000)).until(()->true); + Awaitility.await().pollDelay(Duration.ofMillis(3000)).until(() -> true); } catch (ConditionTimeoutException e) { Assert.fail(e.getMessage()); }