Skip to content

Commit

Permalink
Fix implicit cast from long to int (apache#4209)
Browse files Browse the repository at this point in the history
Fix implicit cast from long to int
  • Loading branch information
hangc0276 authored and Anup Ghatage committed Jul 12, 2024
1 parent c1b5b35 commit b3b545a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ public void removeDeletedLedgers() throws IOException {
}

private ReentrantLock lockForLedger(long ledgerId) {
return locks[Math.abs((int) ledgerId) % locks.length];
return locks[(int) (Math.abs(ledgerId) % locks.length)];
}

int getStorageStateFlags() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public FastTimer(int timeWindowSeconds, Buckets buckets) {
// initialize buckets
int bucketCnt = 0;
for (int i = 0; bucketSpec != null && i < bucketSpec.length; i++) {
bucketCnt += bucketSpec[i][BS_NUMBUCKETS];
bucketCnt += (int) bucketSpec[i][BS_NUMBUCKETS];
}
numBuckets = (bucketCnt > 0 ? bucketCnt + 1 : 0);
if (numBuckets > 0) {
Expand Down Expand Up @@ -349,7 +349,7 @@ public int getBucket(long duration) {
if (duration <= bucketBounds[i]) {
return bucket + (int) ((duration - lowbound - 1) / bucketSpec[i][BS_RESOLUTION]);
} else {
bucket += bucketSpec[i][BS_NUMBUCKETS];
bucket += (int) bucketSpec[i][BS_NUMBUCKETS];
lowbound = bucketBounds[i];
}
}
Expand All @@ -371,7 +371,7 @@ public long getBucketBound(int b) {
if (b < bucket + bucketSpec[i][BS_NUMBUCKETS]) {
return lowbound + ((long) ((b + 1) - bucket)) * bucketSpec[i][BS_RESOLUTION];
} else {
bucket += bucketSpec[i][BS_NUMBUCKETS];
bucket += (int) bucketSpec[i][BS_NUMBUCKETS];
lowbound = bucketBounds[i];
}
}
Expand Down

0 comments on commit b3b545a

Please sign in to comment.