Why clear method in org.apache.lucene.search.LRUQueryCache not clear uniqueQueries

the method is below:
public synchronized void clear() {
this.cache.clear();
this.mostRecentlyUsedQueries.clear();
this.onClear();
}

my question is: why not clear uniqueQueries?
since I will make IndicesQueryCache dynamicly configurable I have to clear the previous one.
but if LRUQueryCache's clear method not clear uniqueQueries, it could be memory leak.

Because mostRecentlyUsedQueries is actually just uniqueQueries.keySet() it means that clearing the former also clears the latter.

thanks very much.

Thank you for asking about it, it indeed looks at first like it might be a memory leak.

I pushed a comment to Lucene's sources to help clarify: