mirror of https://github.com/apache/lucene.git
fix thread safety issue
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1200440 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
32bfbfe380
commit
8a1245cf41
|
@ -252,7 +252,14 @@ public class SearcherLifetimeManager implements Closeable {
|
|||
* from the same background thread that opens new
|
||||
* searchers. */
|
||||
public synchronized void prune(Pruner pruner) throws IOException {
|
||||
final List<SearcherTracker> trackers = new ArrayList<SearcherTracker>(searchers.values());
|
||||
// Cannot just pass searchers.values() to ArrayList ctor
|
||||
// (not thread-safe since the values can change while
|
||||
// ArrayList is init'ing itself); must instead iterate
|
||||
// ourselves:
|
||||
final List<SearcherTracker> trackers = new ArrayList<SearcherTracker>();
|
||||
for(SearcherTracker tracker : searchers.values()) {
|
||||
trackers.add(tracker);
|
||||
}
|
||||
Collections.sort(trackers);
|
||||
final long newestSec = trackers.isEmpty() ? 0L : trackers.get(0).recordTimeSec;
|
||||
for (SearcherTracker tracker: trackers) {
|
||||
|
|
Loading…
Reference in New Issue