LUCENE-3606: Remove IR.clone(readOnly)

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene3606@1210276 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uwe Schindler 2011-12-04 23:29:23 +00:00
parent e1918d8e9c
commit 5586ca1912
3 changed files with 7 additions and 26 deletions

View File

@ -305,25 +305,16 @@ class DirectoryReader extends IndexReader implements Cloneable {
@Override
public final synchronized Object clone() {
try {
return clone(true);
DirectoryReader newReader = doOpenIfChanged((SegmentInfos) segmentInfos.clone(), true, true);
newReader.writer = writer;
newReader.hasDeletions = hasDeletions;
assert newReader.readerFinishedListeners != null;
return newReader;
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
@Override
public final synchronized IndexReader clone(boolean openReadOnly) throws CorruptIndexException, IOException {
assert openReadOnly;
// doOpenIfChanged calls ensureOpen
DirectoryReader newReader = doOpenIfChanged((SegmentInfos) segmentInfos.clone(), true, openReadOnly);
newReader.writer = writer;
newReader.hasDeletions = hasDeletions;
assert newReader.readerFinishedListeners != null;
return newReader;
}
@Override
protected final IndexReader doOpenIfChanged() throws CorruptIndexException, IOException {
return doOpenIfChanged(true, null);

View File

@ -654,16 +654,6 @@ public abstract class IndexReader implements Cloneable,Closeable {
throw new UnsupportedOperationException("This reader does not implement clone()");
}
/**
* Clones the IndexReader and optionally changes readOnly. A readOnly
* reader cannot open a writeable reader.
* @throws CorruptIndexException if the index is corrupt
* @throws IOException if there is a low-level IO error
*/
public synchronized IndexReader clone(boolean openReadOnly) throws CorruptIndexException, IOException {
throw new UnsupportedOperationException("This reader does not implement clone()");
}
/**
* Returns the directory associated with this index. The Default
* implementation returns the directory specified by subclasses when

View File

@ -187,8 +187,8 @@ public class SegmentReader extends IndexReader implements Cloneable {
}
}
@Override
public final synchronized IndexReader clone(boolean openReadOnly) throws CorruptIndexException, IOException {
// nocommit: is this needed anymore by IndexWriter?
final synchronized IndexReader clone(boolean openReadOnly) throws CorruptIndexException, IOException {
return reopenSegment(si, true, openReadOnly);
}