LUCENE-5254: just pass 'this' to the CoreClosedListeners

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1529139 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2013-10-04 12:20:10 +00:00
parent 1ea2fade59
commit ce83d40c67
2 changed files with 6 additions and 10 deletions

View File

@ -53,8 +53,6 @@ final class SegmentCoreReaders {
final FieldsProducer fields;
final DocValuesProducer normsProducer;
private final Object ownerCoreCacheKey;
final StoredFieldsReader fieldsReaderOrig;
final TermVectorsReader termVectorsReaderOrig;
final CompoundFileDirectory cfsReader;
@ -89,11 +87,6 @@ final class SegmentCoreReaders {
SegmentCoreReaders(SegmentReader owner, Directory dir, SegmentInfoPerCommit si, IOContext context) throws IOException {
// SegmentReader uses us as the coreCacheKey; we cannot
// call owner.getCoreCacheKey() because that will return
// null!:
this.ownerCoreCacheKey = this;
final Codec codec = si.info.getCodec();
final Directory cfsDir; // confusing name: if (cfs) its the cfsdir, otherwise its the segment's directory.
@ -175,7 +168,9 @@ final class SegmentCoreReaders {
private void notifyCoreClosedListeners() {
synchronized(coreClosedListeners) {
for (CoreClosedListener listener : coreClosedListeners) {
listener.onClose(ownerCoreCacheKey);
// SegmentReader uses our instance as its
// coreCacheKey:
listener.onClose(this);
}
}
}

View File

@ -407,8 +407,9 @@ public final class SegmentReader extends AtomicReader {
// same entry in the FieldCache. See LUCENE-1579.
@Override
public Object getCoreCacheKey() {
// NOTE: if this every changes, be sure to fix
// SegmentCoreReader's ownerCoreCacheKey to match!
// NOTE: if this ever changes, be sure to fix
// SegmentCoreReader.notifyCoreClosedListeners to match!
// Today it passes "this" as its coreCacheKey:
return core;
}