Skip to content

Commit 3ab4b22

Browse files
author
Ali Beyad
committed
Removes an invalid assert in resizing big arrays which does not always
hold (resizing can result in a smaller size than the current size, while the assert attempted to verify the new size is always greater than the current).
1 parent c67c5c7 commit 3ab4b22

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

core/src/main/java/org/elasticsearch/common/util/BigArrays.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -440,12 +440,11 @@ public CircuitBreakerService breakerService() {
440440

441441
private <T extends AbstractBigArray> T resizeInPlace(T array, long newSize) {
442442
final long oldMemSize = array.ramBytesUsed();
443-
assert oldMemSize == array.ramBytesEstimated(array.size) :
443+
final long oldSize = array.size();
444+
assert oldMemSize == array.ramBytesEstimated(oldSize) :
444445
"ram bytes used should equal that which was previously estimated: ramBytesUsed=" +
445-
oldMemSize + ", ramBytesEstimated=" + array.ramBytesEstimated(array.size);
446+
oldMemSize + ", ramBytesEstimated=" + array.ramBytesEstimated(oldSize);
446447
final long estimatedIncreaseInBytes = array.ramBytesEstimated(newSize) - oldMemSize;
447-
assert estimatedIncreaseInBytes >= 0 :
448-
"estimated increase in bytes for resizing should not be negative: " + estimatedIncreaseInBytes;
449448
adjustBreaker(estimatedIncreaseInBytes, false);
450449
array.resize(newSize);
451450
return array;

0 commit comments

Comments
 (0)