mirror of https://github.com/apache/lucene.git
LUCENE-5362: IndexReader and SegmentCoreReaders now throw AlreadyClosedException if the refCount in incremented but is less that 1.
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1549012 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
101f0b4978
commit
a0745eccea
|
@ -101,6 +101,12 @@ Bug fixes
|
|||
* LUCENE-5285: Improved highlighting of multi-valued fields with
|
||||
FastVectorHighlighter. (Nik Everett via Adrien Grand)
|
||||
|
||||
Changes in Runtime Behavior
|
||||
|
||||
* LUCENE-5362: IndexReader and SegmentCoreReaders now throw
|
||||
AlreadyClosedException if the refCount in incremented but
|
||||
is less that 1. (Simon Willnauer)
|
||||
|
||||
======================= Lucene 4.6.0 =======================
|
||||
|
||||
New Features
|
||||
|
|
|
@ -168,8 +168,9 @@ public abstract class IndexReader implements Closeable {
|
|||
* @see #tryIncRef
|
||||
*/
|
||||
public final void incRef() {
|
||||
ensureOpen();
|
||||
refCount.incrementAndGet();
|
||||
if (!tryIncRef()) {
|
||||
ensureOpen();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.apache.lucene.codecs.PostingsFormat;
|
|||
import org.apache.lucene.codecs.StoredFieldsReader;
|
||||
import org.apache.lucene.codecs.TermVectorsReader;
|
||||
import org.apache.lucene.index.SegmentReader.CoreClosedListener;
|
||||
import org.apache.lucene.store.AlreadyClosedException;
|
||||
import org.apache.lucene.store.CompoundFileDirectory;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.store.IOContext;
|
||||
|
@ -139,7 +140,13 @@ final class SegmentCoreReaders {
|
|||
}
|
||||
|
||||
void incRef() {
|
||||
ref.incrementAndGet();
|
||||
int count;
|
||||
while ((count = ref.get()) > 0) {
|
||||
if (ref.compareAndSet(count, count+1)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new AlreadyClosedException("SegmentCoreReaders is already closed");
|
||||
}
|
||||
|
||||
NumericDocValues getNormValues(FieldInfo fi) throws IOException {
|
||||
|
|
Loading…
Reference in New Issue