From 1f7be7931bcee59d45b59fd98827c860e41e3e50 Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Mon, 25 Aug 2014 16:25:02 +0200 Subject: [PATCH] [TEST] fix issue clearing fielddata breaker introduced in 6950c38a0436ec937797f01fba8d7d95e6d6225f --- .../indices/fielddata/cache/IndicesFieldDataCache.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/elasticsearch/indices/fielddata/cache/IndicesFieldDataCache.java b/src/main/java/org/elasticsearch/indices/fielddata/cache/IndicesFieldDataCache.java index dd54b817e9e..d1cc34ba807 100644 --- a/src/main/java/org/elasticsearch/indices/fielddata/cache/IndicesFieldDataCache.java +++ b/src/main/java/org/elasticsearch/indices/fielddata/cache/IndicesFieldDataCache.java @@ -113,7 +113,10 @@ public class IndicesFieldDataCache extends AbstractComponent implements RemovalL IndexFieldCache indexCache = key.indexCache; long sizeInBytes = key.sizeInBytes; final Accountable value = notification.getValue(); - assert value == null || sizeInBytes > 0 && sizeInBytes == value.ramBytesUsed() : "Expected size [" + sizeInBytes + "] to be positive or value [" + value + "] to be non-null"; + assert sizeInBytes >= 0 || value != null : "Expected size [" + sizeInBytes + "] to be positive or value [" + value + "] to be non-null"; + if (sizeInBytes == -1 && value != null) { + sizeInBytes = value.ramBytesUsed(); + } for (IndexFieldDataCache.Listener listener : key.listeners) { try { listener.onUnload(indexCache.fieldNames, indexCache.fieldDataType, notification.wasEvicted(), sizeInBytes); @@ -220,7 +223,6 @@ public class IndicesFieldDataCache extends AbstractComponent implements RemovalL logger.error("Failed to call listener on global ordinals loading", e); } } - key.sizeInBytes = ifd.ramBytesUsed(); return ifd; } });