void evictIfNecessary() { assert lock.isHeldByCurrentThread(); // under a lock to make sure that mostRecentlyUsedQueries and cache keep sync'ed if (requiresEviction()) { Iterator<Query> iterator = mostRecentlyUsedQueries.iterator(); do { final Query query = iterator.next(); final int size = mostRecentlyUsedQueries.size(); iterator.remove(); if (size == mostRecentlyUsedQueries.size()) { // size did not decrease, because the hash of the query changed since it has been // put into the cache throw new ConcurrentModificationException("Removal from the cache failed! This " + "is probably due to a query which has been modified after having been put into " + " the cache or a badly implemented clone(). Query class: [" + query.getClass() + "], query: [" + query + "]"); } onEviction(query); } while (iterator.hasNext() && requiresEviction()); } }
void assertConsistent() { lock.lock(); try { if (requiresEviction()) { throw new AssertionError("requires evictions: size=" + mostRecentlyUsedQueries.size() + ", maxSize=" + maxSize + ", ramBytesUsed=" + ramBytesUsed() + ", maxRamBytesUsed=" + maxRamBytesUsed);
synchronized void evictIfNecessary() { // under a lock to make sure that mostRecentlyUsedQueries and cache keep sync'ed if (requiresEviction()) { Iterator<Query> iterator = mostRecentlyUsedQueries.iterator(); do { final Query query = iterator.next(); final int size = mostRecentlyUsedQueries.size(); iterator.remove(); if (size == mostRecentlyUsedQueries.size()) { // size did not decrease, because the hash of the query changed since it has been // put into the cache throw new ConcurrentModificationException("Removal from the cache failed! This " + "is probably due to a query which has been modified after having been put into " + " the cache or a badly implemented clone(). Query class: [" + query.getClass() + "], query: [" + query + "]"); } onEviction(query); } while (iterator.hasNext() && requiresEviction()); } }
synchronized void evictIfNecessary() { // under a lock to make sure that mostRecentlyUsedQueries and cache keep sync'ed if (requiresEviction()) { Iterator<Query> iterator = mostRecentlyUsedQueries.iterator(); do { final Query query = iterator.next(); final int size = mostRecentlyUsedQueries.size(); iterator.remove(); if (size == mostRecentlyUsedQueries.size()) { // size did not decrease, because the hash of the query changed since it has been // put into the cache throw new ConcurrentModificationException("Removal from the cache failed! This " + "is probably due to a query which has been modified after having been put into " + " the cache or a badly implemented clone(). Query class: [" + query.getClass() + "], query: [" + query + "]"); } onEviction(query); } while (iterator.hasNext() && requiresEviction()); } }
void evictIfNecessary() { assert lock.isHeldByCurrentThread(); // under a lock to make sure that mostRecentlyUsedQueries and cache keep sync'ed if (requiresEviction()) { Iterator<Query> iterator = mostRecentlyUsedQueries.iterator(); do { final Query query = iterator.next(); final int size = mostRecentlyUsedQueries.size(); iterator.remove(); if (size == mostRecentlyUsedQueries.size()) { // size did not decrease, because the hash of the query changed since it has been // put into the cache throw new ConcurrentModificationException("Removal from the cache failed! This " + "is probably due to a query which has been modified after having been put into " + " the cache or a badly implemented clone(). Query class: [" + query.getClass() + "], query: [" + query + "]"); } onEviction(query); } while (iterator.hasNext() && requiresEviction()); } }
synchronized void assertConsistent() { if (requiresEviction()) { throw new AssertionError("requires evictions: size=" + mostRecentlyUsedQueries.size() + ", maxSize=" + maxSize + ", ramBytesUsed=" + ramBytesUsed() + ", maxRamBytesUsed=" + maxRamBytesUsed);
void assertConsistent() { lock.lock(); try { if (requiresEviction()) { throw new AssertionError("requires evictions: size=" + mostRecentlyUsedQueries.size() + ", maxSize=" + maxSize + ", ramBytesUsed=" + ramBytesUsed() + ", maxRamBytesUsed=" + maxRamBytesUsed);
synchronized void assertConsistent() { if (requiresEviction()) { throw new AssertionError("requires evictions: size=" + mostRecentlyUsedQueries.size() + ", maxSize=" + maxSize + ", ramBytesUsed=" + ramBytesUsed() + ", maxRamBytesUsed=" + maxRamBytesUsed);