From 3bfdefc2e661cad9153fd52c7a14c222180c8407 Mon Sep 17 00:00:00 2001 From: Anton Shalkovich Date: Fri, 30 Jun 2023 18:33:36 +0200 Subject: [PATCH] Squash of two similar checks, not null check for "restriction.milisToRun" before unboxing the primitive (#27304) Co-authored-by: Anton_Shalkovich --- .../apache/beam/io/debezium/KafkaSourceConsumerFn.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/sdks/java/io/debezium/src/main/java/org/apache/beam/io/debezium/KafkaSourceConsumerFn.java b/sdks/java/io/debezium/src/main/java/org/apache/beam/io/debezium/KafkaSourceConsumerFn.java index 96955afdc860..8bab4fdcc7af 100644 --- a/sdks/java/io/debezium/src/main/java/org/apache/beam/io/debezium/KafkaSourceConsumerFn.java +++ b/sdks/java/io/debezium/src/main/java/org/apache/beam/io/debezium/KafkaSourceConsumerFn.java @@ -400,15 +400,13 @@ public boolean tryClaim(Map position) { this.restriction.fetchedRecords = fetchedRecords; LOG.debug("-------------- History: {}", this.restriction.history); - if (this.restriction.maxRecords == null && this.restriction.milisToRun == -1) { - return true; - } - // If we've reached the maximum number of records OR the maximum time, we reject // the attempt to claim. // If we've reached neither, then we continue approve the claim. return (this.restriction.maxRecords == null || fetchedRecords < this.restriction.maxRecords) - && (this.restriction.milisToRun == null || elapsedTime < this.restriction.milisToRun); + && (this.restriction.milisToRun == null + || this.restriction.milisToRun == -1 + || elapsedTime < this.restriction.milisToRun); } @Override