diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/body/ConsumerRunningInfo.java b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/body/ConsumerRunningInfo.java index 542f9300678..daa0fbe62eb 100644 --- a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/body/ConsumerRunningInfo.java +++ b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/body/ConsumerRunningInfo.java @@ -57,11 +57,10 @@ public static boolean analyzeSubscription(final TreeMap (1000 * 60 * 2); } - startForAWhile = (System.currentTimeMillis() - Long.parseLong(property)) > (1000 * 60 * 2); } if (push && startForAWhile) { @@ -96,12 +95,12 @@ public static boolean analyzeSubscription(final TreeMap criTable) { @@ -110,15 +109,7 @@ public static boolean analyzeRebalance(final TreeMap()); + + TreeMap table = new TreeMap<>(); + table.put("client_id_1", consumerRunningInfo); + table.put("client_id_2", another); + + assertThat(ConsumerRunningInfo.analyzeSubscription(table)).isTrue(); + } + + @Test + public void testAnalyzeMethodsTolerateMissingProperties() { + ConsumerRunningInfo empty = new ConsumerRunningInfo(); + empty.setProperties(new Properties()); + + assertThat(ConsumerRunningInfo.isPushType(empty)).isFalse(); + assertThat(ConsumerRunningInfo.analyzeProcessQueue("client_id", empty)).isEmpty(); + + TreeMap table = new TreeMap<>(); + table.put("client_id", empty); + assertThat(ConsumerRunningInfo.analyzeSubscription(table)).isTrue(); + } + + @Test + public void testIsPushType() { + assertThat(ConsumerRunningInfo.isPushType(consumerRunningInfo)).isFalse(); + + Properties properties = new Properties(); + properties.put(ConsumerRunningInfo.PROP_CONSUME_TYPE, ConsumeType.CONSUME_PASSIVELY.name()); + consumerRunningInfo.setProperties(properties); + assertThat(ConsumerRunningInfo.isPushType(consumerRunningInfo)).isTrue(); + } + }