MINOR: Avoid dividing by zero
Reviews: A. Sophie Blee-Goldman Bill Bejeck Bruno Cadonna Boyang Chen Guozhang Wang
@@ -1042,7 +1042,7 @@ public class StreamThread extends Thread {
* 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 @@ public class StreamThread extends Thread {
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 @@ public class StreamThread extends Thread {
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;
}
}
