From 2a5c45947dd64cf28782d43e298cd3e07748a0c9 Mon Sep 17 00:00:00 2001 From: Doug Cutting Date: Thu, 11 Oct 2001 22:44:23 +0000 Subject: [PATCH] Fixed potential race condition. git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@149611 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/lucene/index/SegmentsReader.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/java/org/apache/lucene/index/SegmentsReader.java b/src/java/org/apache/lucene/index/SegmentsReader.java index 4ab2197dc04..607641a8e15 100644 --- a/src/java/org/apache/lucene/index/SegmentsReader.java +++ b/src/java/org/apache/lucene/index/SegmentsReader.java @@ -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