mirror of https://github.com/apache/lucene.git
Fixed potential race condition.
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@149611 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6369c5a884
commit
2a5c45947d
|
@ -77,7 +77,7 @@ final class SegmentsReader extends IndexReader {
|
|||
starts[readers.length] = maxDoc;
|
||||
}
|
||||
|
||||
public final int numDocs() {
|
||||
public synchronized final int numDocs() {
|
||||
if (numDocs == -1) { // check cache
|
||||
int n = 0; // cache miss--recompute
|
||||
for (int i = 0; i < readers.length; i++)
|
||||
|
@ -101,7 +101,7 @@ final class SegmentsReader extends IndexReader {
|
|||
return readers[i].isDeleted(n - starts[i]); // dispatch to segment reader
|
||||
}
|
||||
|
||||
public final void delete(int n) throws IOException {
|
||||
public synchronized final void delete(int n) throws IOException {
|
||||
numDocs = -1; // invalidate cache
|
||||
int i = readerIndex(n); // find segment num
|
||||
readers[i].delete(n - starts[i]); // dispatch to segment reader
|
||||
|
|
Loading…
Reference in New Issue