[cleanup][broker] Remove consumer null-check in trySendMessagesToConsumers
@@ -234,10 +234,11 @@ public class PersistentStickyKeyDispatcherMultipleConsumers extends PersistentDi
}
for (Map.Entry<Consumer, List<Entry>> current : groupedEntries.entrySet()) {
Consumer consumer = current.getKey();
+ assert consumer != null; // checked when added to groupedEntries
List<Entry> entriesWithSameKey = current.getValue();
int entriesWithSameKeyCount = entriesWithSameKey.size();
- int availablePermits = consumer == null ? 0 : Math.max(consumer.getAvailablePermits(), 0);
- if (consumer != null && consumer.getMaxUnackedMessages() > 0) {
+ int availablePermits = Math.max(consumer.getAvailablePermits(), 0);
+ if (consumer.getMaxUnackedMessages() > 0) {
int remainUnAckedMessages =
// Avoid negative number
Math.max(consumer.getMaxUnackedMessages() - consumer.getUnackedMessages(), 0);
@@ -248,7 +249,7 @@ public class PersistentStickyKeyDispatcherMultipleConsumers extends PersistentDi
readType, consumerStickyKeyHashesMap.get(consumer));
if (log.isDebugEnabled()) {
log.debug("[{}] select consumer {} with messages num {}, read type is {}",
- name, consumer == null ? "null" : consumer.consumerName(), messagesForC, readType);
+ name, consumer.consumerName(), messagesForC, readType);
}
if (messagesForC < entriesWithSameKeyCount) {
