diff --git a/streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamThread.java b/streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamThread.java index 1633b30223b62..d3efa9e0e05de 100644 --- a/streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamThread.java +++ b/streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamThread.java @@ -1042,7 +1042,7 @@ private boolean maybePunctuate() { * or if the task producer got fenced (EOS) */ boolean maybeCommit() { - int committed = 0; + final int committed; if (now - lastCommitMs > commitTimeMs) { if (log.isTraceEnabled()) { @@ -1050,7 +1050,7 @@ boolean maybeCommit() { taskManager.activeTaskIds(), taskManager.standbyTaskIds(), now - lastCommitMs, commitTimeMs); } - committed += taskManager.commitAll(); + committed = taskManager.commitAll(); if (committed > 0) { final long intervalCommitLatency = advanceNowAndComputeLatency(); commitSensor.record(intervalCommitLatency / (double) committed, now); @@ -1067,11 +1067,10 @@ boolean maybeCommit() { lastCommitMs = now; processStandbyRecords = true; } else { - final int commitPerRequested = taskManager.maybeCommitActiveTasksPerUserRequested(); - if (commitPerRequested > 0) { + committed = taskManager.maybeCommitActiveTasksPerUserRequested(); + if (committed > 0) { final long requestCommitLatency = advanceNowAndComputeLatency(); commitSensor.record(requestCommitLatency / (double) committed, now); - committed += commitPerRequested; } }