blob: 1814b127d2992987fda0e91705e5050c283dea32 [file] [log] [blame]
Index: lucene/src/java/org/apache/lucene/index/MultiReader.java
===================================================================
--- lucene/src/java/org/apache/lucene/index/MultiReader.java (revision 1212756)
+++ lucene/src/java/org/apache/lucene/index/MultiReader.java (working copy)
@@ -88,54 +88,22 @@
readerFinishedListeners = new MapBackedSet<ReaderFinishedListener>(new ConcurrentHashMap<ReaderFinishedListener,Boolean>());
}
- /**
- * Tries to reopen the subreaders.
- * <br>
- * If one or more subreaders could be re-opened (i. e. IndexReader.openIfChanged(subReader)
- * returned a new instance), then a new MultiReader instance
- * is returned, otherwise this instance is returned.
- * <p>
- * A re-opened instance might share one or more subreaders with the old
- * instance. Index modification operations result in undefined behavior
- * when performed before the old instance is closed.
- * (see {@link IndexReader#openIfChanged}).
- * <p>
- * If subreaders are shared, then the reference count of those
- * readers is increased to ensure that the subreaders remain open
- * until the last referring reader is closed.
- *
- * @throws CorruptIndexException if the index is corrupt
- * @throws IOException if there is a low-level IO error
- */
@Override
protected synchronized IndexReader doOpenIfChanged() throws CorruptIndexException, IOException {
return doReopen(false);
}
/**
- * If the index has changed since it was opened, open and return a new reader;
- * else, return {@code null}.
- *
- * @see #openIfChanged(IndexReader, boolean)
+ * @throws UnsupportedOperationException MultiReaders cannot support changing the readOnly flag
* @deprecated Write support will be removed in Lucene 4.0.
- * Use {@link #doOpenIfChanged()} instead
+ * Use {@link #doOpenIfChanged()} instead.
*/
@Deprecated @Override
protected IndexReader doOpenIfChanged(boolean openReadOnly) throws CorruptIndexException, IOException {
- if (!openReadOnly)
- throw new UnsupportedOperationException("MultiReader does not support reopening in read/write mode");
- return doReopen(false);
+ throw new UnsupportedOperationException("MultiReader does not support reopening with changing readOnly flag. "+
+ "Use IndexReader.openIfChanged(IndexReader) instead.");
}
- /**
- * Clones the subreaders.
- * (see {@link IndexReader#clone()}).
- * <br>
- * <p>
- * If subreaders are shared, then the reference count of those
- * readers is increased to ensure that the subreaders remain open
- * until the last referring reader is closed.
- */
@Override
public synchronized Object clone() {
try {
@@ -146,6 +114,17 @@
}
/**
+ * @throws UnsupportedOperationException MultiReaders cannot support changing the readOnly flag
+ * @deprecated Write support will be removed in Lucene 4.0.
+ * Use {@link #clone()} instead.
+ */
+ @Override @Deprecated
+ public IndexReader clone(boolean openReadOnly) throws CorruptIndexException, IOException {
+ throw new UnsupportedOperationException("MultiReader does not support cloning with changing readOnly flag. "+
+ "Use IndexReader.clone() instead.");
+ }
+
+ /**
* If clone is true then we clone each of the subreaders
* @param doClone
* @return New IndexReader, or null if open/clone is not necessary
Index: lucene/src/java/org/apache/lucene/index/ParallelReader.java
===================================================================
--- lucene/src/java/org/apache/lucene/index/ParallelReader.java (revision 1212756)
+++ lucene/src/java/org/apache/lucene/index/ParallelReader.java (working copy)
@@ -140,8 +140,23 @@
}
@Override
+ protected synchronized IndexReader doOpenIfChanged() throws CorruptIndexException, IOException {
+ return doReopen(false);
+ }
+
+ /**
+ * @throws UnsupportedOperationException ParallelReaders cannot support changing the readOnly flag
+ * @deprecated Write support will be removed in Lucene 4.0.
+ * Use {@link #doOpenIfChanged()} instead.
+ */
+ @Deprecated @Override
+ protected IndexReader doOpenIfChanged(boolean openReadOnly) throws CorruptIndexException, IOException {
+ throw new UnsupportedOperationException("ParallelReader does not support reopening with changing readOnly flag. "+
+ "Use IndexReader.openIfChanged(IndexReader) instead.");
+ }
+
+ @Override
public synchronized Object clone() {
- // doReopen calls ensureOpen
try {
return doReopen(true);
} catch (Exception ex) {
@@ -150,43 +165,14 @@
}
/**
- * Tries to reopen the subreaders.
- * <br>
- * If one or more subreaders could be re-opened (i. e. subReader.reopen()
- * returned a new instance != subReader), then a new ParallelReader instance
- * is returned, otherwise null is returned.
- * <p>
- * A re-opened instance might share one or more subreaders with the old
- * instance. Index modification operations result in undefined behavior
- * when performed before the old instance is closed.
- * (see {@link IndexReader#openIfChanged}).
- * <p>
- * If subreaders are shared, then the reference count of those
- * readers is increased to ensure that the subreaders remain open
- * until the last referring reader is closed.
- *
- * @throws CorruptIndexException if the index is corrupt
- * @throws IOException if there is a low-level IO error
- */
- @Override
- protected synchronized IndexReader doOpenIfChanged() throws CorruptIndexException, IOException {
- // doReopen calls ensureOpen
- return doReopen(false);
- }
-
- /**
- * If the index has changed since it was opened, open and return a new reader;
- * else, return {@code null}.
- *
- * @see #openIfChanged(IndexReader, boolean)
+ * @throws UnsupportedOperationException ParallelReaders cannot support changing the readOnly flag
* @deprecated Write support will be removed in Lucene 4.0.
- * Use {@link #doOpenIfChanged()} instead
+ * Use {@link #clone()} instead.
*/
- @Deprecated @Override
- protected IndexReader doOpenIfChanged(boolean openReadOnly) throws CorruptIndexException, IOException {
- if (!openReadOnly)
- throw new UnsupportedOperationException("ParallelReader does not support reopening in read/write mode");
- return doReopen(false);
+ @Override @Deprecated
+ public IndexReader clone(boolean openReadOnly) throws CorruptIndexException, IOException {
+ throw new UnsupportedOperationException("ParallelReader does not support cloning with changing readOnly flag. "+
+ "Use IndexReader.clone() instead.");
}
private IndexReader doReopen(boolean doClone) throws CorruptIndexException, IOException {