Skip to content

Commit

Permalink
Squash of two similar checks, not null check for "restriction.milisTo…
Browse files Browse the repository at this point in the history
…Run" before unboxing the primitive (apache#27304)

Co-authored-by: Anton_Shalkovich <[email protected]>
  • Loading branch information
2 people authored and cushon committed May 24, 2024
1 parent ee1c35b commit 3bfdefc
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -400,15 +400,13 @@ public boolean tryClaim(Map<String, Object> 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
Expand Down

0 comments on commit 3bfdefc

Please sign in to comment.