Github user HeartSaVioR commented on a diff in the pull request:
https://github.com/apache/storm/pull/2380#discussion_r147025420
--- Diff:
external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpout.java
---
@@ -438,55 +440,53 @@ private void commitOffsetsForAckedTuples() {
// ======== Ack =======
@Override
public void ack(Object messageId) {
- if (!isAtLeastOnce()) {
- // Only need to keep track of acked tuples if commits are done
based on acks
- return;
- }
-
+ // Only need to keep track of acked tuples if commits to Kafka are
done after a tuple ack is received
final KafkaSpoutMessageId msgId = (KafkaSpoutMessageId) messageId;
- if (!emitted.contains(msgId)) {
- if (msgId.isEmitted()) {
- LOG.debug("Received ack for message [{}], associated with
tuple emitted for a ConsumerRecord that "
- + "came from a topic-partition that this consumer
group instance is no longer tracking "
- + "due to rebalance/partition reassignment. No action
taken.", msgId);
+ if (isAtLeastOnceProcessing()) {
--- End diff --
I know there's a huge debate on if else vs early return, but I'm in favor
of early return, especially it is used as some pruning on early stage of logic.
Sure I'm not in favor of second statements (if do nothing else do action)
but early return is completely different as do nothing, as it does pruning the
logic branch and no need to follow the if statement and statements after end of
if statement.
---