Skip to content

Use Math.min() in ExponentialBackOff #25381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ public ByteVector putByteArray(
private void enlarge(final int size) {
int doubleCapacity = 2 * data.length;
int minimalCapacity = length + size;
byte[] newData = new byte[doubleCapacity > minimalCapacity ? doubleCapacity : minimalCapacity];
byte[] newData = new byte[Math.max(doubleCapacity, minimalCapacity)];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please refrain from modifying classes under org.springframework.asm, org.springframework.cglib, and org.springframework.objenesis. Those include repackaged forks of the third-party libraries ASM, CGLIB, and Objenesis. Any refactoring to those classes should take place upstream in the originating repository. The Spring Framework will then pick up the changes when syncing with official updates of the forked third-party libraries.


Note, however, that there is no need to update this PR. I'll simply revert that before merging.

System.arraycopy(data, 0, newData, 0, length);
data = newData;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,7 @@ private long computeNextInterval() {
}
else if (this.currentInterval < 0) {
long initialInterval = getInitialInterval();
this.currentInterval = (initialInterval < maxInterval
? initialInterval : maxInterval);
this.currentInterval = (Math.min(initialInterval, maxInterval));
}
else {
this.currentInterval = multiplyInterval(maxInterval);
Expand All @@ -212,7 +211,7 @@ else if (this.currentInterval < 0) {
private long multiplyInterval(long maxInterval) {
long i = this.currentInterval;
i *= getMultiplier();
return (i > maxInterval ? maxInterval : i);
return (Math.min(i, maxInterval));
}


Expand Down