From 893e8fd8881a1acdc18020016450463d642baa59 Mon Sep 17 00:00:00 2001 From: qingjiyuji <1114366223@qq.com> Date: Thu, 24 Jun 2021 02:11:06 +0800 Subject: [PATCH] code style(client):polish lite pull consumer code style --- .../impl/consumer/DefaultLitePullConsumerImpl.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultLitePullConsumerImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultLitePullConsumerImpl.java index b1caeede..e835be1c 100644 --- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultLitePullConsumerImpl.java +++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultLitePullConsumerImpl.java @@ -466,7 +466,7 @@ public class DefaultLitePullConsumerImpl implements MQConsumerInner { public synchronized void subscribe(String topic, String subExpression) throws MQClientException { try { - if (topic == null || topic.equals("")) { + if (topic == null || "".equals(topic)) { throw new IllegalArgumentException("Topic can not be null or empty."); } setSubscriptionType(SubscriptionType.SUBSCRIBE); @@ -485,7 +485,7 @@ public class DefaultLitePullConsumerImpl implements MQConsumerInner { public synchronized void subscribe(String topic, MessageSelector messageSelector) throws MQClientException { try { - if (topic == null || topic.equals("")) { + if (topic == null || "".equals(topic)) { throw new IllegalArgumentException("Topic can not be null or empty."); } setSubscriptionType(SubscriptionType.SUBSCRIBE); @@ -741,7 +741,7 @@ public class DefaultLitePullConsumerImpl implements MQConsumerInner { return; } - if (consumeRequestCache.size() * defaultLitePullConsumer.getPullBatchSize() > defaultLitePullConsumer.getPullThresholdForAll()) { + if ((long) consumeRequestCache.size() * defaultLitePullConsumer.getPullBatchSize() > defaultLitePullConsumer.getPullThresholdForAll()) { scheduledThreadPoolExecutor.schedule(this, PULL_TIME_DELAY_MILLS_WHEN_FLOW_CONTROL, TimeUnit.MILLISECONDS); if ((consumeRequestFlowControlTimes++ % 1000) == 0) { log.warn("The consume request count exceeds threshold {}, so do flow control, consume request count={}, flowControlTimes={}", consumeRequestCache.size(), consumeRequestFlowControlTimes); @@ -797,11 +797,10 @@ public class DefaultLitePullConsumerImpl implements MQConsumerInner { long pullDelayTimeMills = 0; try { SubscriptionData subscriptionData; + String topic = this.messageQueue.getTopic(); if (subscriptionType == SubscriptionType.SUBSCRIBE) { - String topic = this.messageQueue.getTopic(); subscriptionData = rebalanceImpl.getSubscriptionInner().get(topic); } else { - String topic = this.messageQueue.getTopic(); subscriptionData = FilterAPI.buildSubscriptionData(topic, SubscriptionData.SUB_ALL); } -- GitLab