mirror of https://github.com/apache/lucene.git
LUCENE-3409: don't use Iterator.remove
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1163589 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ca0f81543c
commit
81d22a27ba
|
@ -27,7 +27,6 @@ import java.util.Comparator;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -601,20 +600,15 @@ public class IndexWriter implements Closeable, TwoPhaseCommit {
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void dropAll() throws IOException {
|
public synchronized void dropAll() throws IOException {
|
||||||
Iterator<Map.Entry<SegmentCacheKey,SegmentReader>> iter = readerMap.entrySet().iterator();
|
for(SegmentReader reader : readerMap.values()) {
|
||||||
while (iter.hasNext()) {
|
reader.hasChanges = false;
|
||||||
|
|
||||||
final Map.Entry<SegmentCacheKey,SegmentReader> ent = iter.next();
|
|
||||||
|
|
||||||
SegmentReader sr = ent.getValue();
|
|
||||||
sr.hasChanges = false;
|
|
||||||
iter.remove();
|
|
||||||
|
|
||||||
// NOTE: it is allowed that this decRef does not
|
// NOTE: it is allowed that this decRef does not
|
||||||
// actually close the SR; this can happen when a
|
// actually close the SR; this can happen when a
|
||||||
// near real-time reader using this SR is still open
|
// near real-time reader using this SR is still open
|
||||||
sr.decRef();
|
reader.decRef();
|
||||||
}
|
}
|
||||||
|
readerMap.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void drop(SegmentInfo info, IOContext.Context context) throws IOException {
|
public synchronized void drop(SegmentInfo info, IOContext.Context context) throws IOException {
|
||||||
|
@ -633,10 +627,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit {
|
||||||
// sync'd on IW:
|
// sync'd on IW:
|
||||||
assert Thread.holdsLock(IndexWriter.this);
|
assert Thread.holdsLock(IndexWriter.this);
|
||||||
|
|
||||||
Iterator<Map.Entry<SegmentCacheKey,SegmentReader>> iter = readerMap.entrySet().iterator();
|
for(Map.Entry<SegmentCacheKey,SegmentReader> ent : readerMap.entrySet()) {
|
||||||
while (iter.hasNext()) {
|
|
||||||
|
|
||||||
Map.Entry<SegmentCacheKey,SegmentReader> ent = iter.next();
|
|
||||||
|
|
||||||
SegmentReader sr = ent.getValue();
|
SegmentReader sr = ent.getValue();
|
||||||
if (sr.hasChanges) {
|
if (sr.hasChanges) {
|
||||||
|
@ -649,14 +640,14 @@ public class IndexWriter implements Closeable, TwoPhaseCommit {
|
||||||
deleter.checkpoint(segmentInfos, false);
|
deleter.checkpoint(segmentInfos, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
iter.remove();
|
|
||||||
|
|
||||||
// NOTE: it is allowed that this decRef does not
|
// NOTE: it is allowed that this decRef does not
|
||||||
// actually close the SR; this can happen when a
|
// actually close the SR; this can happen when a
|
||||||
// near real-time reader is kept open after the
|
// near real-time reader is kept open after the
|
||||||
// IndexWriter instance is closed
|
// IndexWriter instance is closed
|
||||||
sr.decRef();
|
sr.decRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
readerMap.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue