mirror of
https://github.com/apache/lucene.git
synced 2025-02-08 02:58:58 +00:00
LUCENE-2273: Fixed bug in FieldCacheImpl.getCacheEntries() that used WeakHashMap incorrectly and lead to ConcurrentModificationException
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@912330 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0f99c02ee5
commit
fbe34a8500
@ -82,6 +82,10 @@ Bug fixes
|
||||
* LUCENE-2249: ParallelMultiSearcher should shut down thread pool on
|
||||
close. (Martin Traverso via Uwe Schindler)
|
||||
|
||||
* LUCENE-2273: FieldCacheImpl.getCacheEntries() used WeakHashMap
|
||||
incorrectly and lead to ConcurrentModificationException.
|
||||
(Uwe Schindler, Robert Muir)
|
||||
|
||||
New features
|
||||
|
||||
* LUCENE-2128: Parallelized fetching document frequencies during weight
|
||||
|
@ -58,27 +58,25 @@ class FieldCacheImpl implements FieldCache {
|
||||
caches.put(StringIndex.class, new StringIndexCache(this));
|
||||
}
|
||||
|
||||
public void purgeAllCaches() {
|
||||
public synchronized void purgeAllCaches() {
|
||||
init();
|
||||
}
|
||||
|
||||
public void purge(IndexReader r) {
|
||||
public synchronized void purge(IndexReader r) {
|
||||
for(Cache c : caches.values()) {
|
||||
c.purge(r);
|
||||
}
|
||||
}
|
||||
|
||||
public CacheEntry[] getCacheEntries() {
|
||||
public synchronized CacheEntry[] getCacheEntries() {
|
||||
List<CacheEntry> result = new ArrayList<CacheEntry>(17);
|
||||
for(final Class<?> cacheType: caches.keySet()) {
|
||||
Cache cache = caches.get(cacheType);
|
||||
for (final Object readerKey : cache.readerCache.keySet()) {
|
||||
// we've now materialized a hard ref
|
||||
|
||||
// innerKeys was backed by WeakHashMap, sanity check
|
||||
// that it wasn't GCed before we made hard ref
|
||||
if (null != readerKey && cache.readerCache.containsKey(readerKey)) {
|
||||
Map<Entry, Object> innerCache = cache.readerCache.get(readerKey);
|
||||
for(final Map.Entry<Class<?>,Cache> cacheEntry: caches.entrySet()) {
|
||||
final Cache cache = cacheEntry.getValue();
|
||||
final Class<?> cacheType = cacheEntry.getKey();
|
||||
synchronized(cache.readerCache) {
|
||||
for (final Map.Entry<Object,Map<Entry, Object>> readerCacheEntry : cache.readerCache.entrySet()) {
|
||||
final Object readerKey = readerCacheEntry.getKey();
|
||||
final Map<Entry, Object> innerCache = readerCacheEntry.getValue();
|
||||
for (final Map.Entry<Entry, Object> mapEntry : innerCache.entrySet()) {
|
||||
Entry entry = mapEntry.getKey();
|
||||
result.add(new CacheEntryImpl(readerKey, entry.field,
|
||||
|
Loading…
x
Reference in New Issue
Block a user