LUCENE-6076: Fix locking in CachingWrapperFilter.getChildResources.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1641822 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Adrien Grand 2014-11-26 14:26:43 +00:00
parent f12d1e0983
commit 86e6db22f7
1 changed files with 8 additions and 3 deletions

View File

@ -22,6 +22,7 @@ import static org.apache.lucene.search.DocIdSet.EMPTY;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
@ -146,8 +147,12 @@ public class CachingWrapperFilter extends Filter implements Accountable {
}
@Override
public synchronized Iterable<? extends Accountable> getChildResources() {
// Sync only to pull the current set of values:
return Accountables.namedAccountables("segment", cache);
public Iterable<? extends Accountable> getChildResources() {
// Sync to pull the current set of values:
final Map<Object, DocIdSet> copy;
synchronized (cache) {
copy = new HashMap<>(cache);
}
return Accountables.namedAccountables("segment", copy);
}
}