From f2a23e3459df83d6fb5ecc1d2705f8c13aa1cb2d Mon Sep 17 00:00:00 2001 From: Ali Beyad Date: Mon, 5 Jun 2017 11:49:06 -0400 Subject: [PATCH] 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). --- .../main/java/org/elasticsearch/common/util/BigArrays.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/common/util/BigArrays.java b/core/src/main/java/org/elasticsearch/common/util/BigArrays.java index 8752e5b4bee..5c539a791cf 100644 --- a/core/src/main/java/org/elasticsearch/common/util/BigArrays.java +++ b/core/src/main/java/org/elasticsearch/common/util/BigArrays.java @@ -440,12 +440,11 @@ public class BigArrays implements Releasable { private T resizeInPlace(T array, long newSize) { final long oldMemSize = array.ramBytesUsed(); - assert oldMemSize == array.ramBytesEstimated(array.size) : + final long oldSize = array.size(); + assert oldMemSize == array.ramBytesEstimated(oldSize) : "ram bytes used should equal that which was previously estimated: ramBytesUsed=" + - oldMemSize + ", ramBytesEstimated=" + array.ramBytesEstimated(array.size); + oldMemSize + ", ramBytesEstimated=" + array.ramBytesEstimated(oldSize); final long estimatedIncreaseInBytes = array.ramBytesEstimated(newSize) - oldMemSize; - assert estimatedIncreaseInBytes >= 0 : - "estimated increase in bytes for resizing should not be negative: " + estimatedIncreaseInBytes; adjustBreaker(estimatedIncreaseInBytes, false); array.resize(newSize); return array;