LUCENE-3147: reinstate calling checkpoint() from IW.closeMergeReaders

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1128924 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shai Erera 2011-05-29 18:36:54 +00:00
parent 5fc94ed766
commit e8ce61f9db
1 changed files with 8 additions and 3 deletions

View File

@ -3334,11 +3334,12 @@ public class IndexWriter implements Closeable {
final int numSegments = merge.readers.size(); final int numSegments = merge.readers.size();
Throwable th = null; Throwable th = null;
boolean anyChanges = false;
boolean drop = !suppressExceptions; boolean drop = !suppressExceptions;
for (int i = 0; i < numSegments; i++) { for (int i = 0; i < numSegments; i++) {
if (merge.readers.get(i) != null) { if (merge.readers.get(i) != null) {
try { try {
readerPool.release(merge.readers.get(i), drop); anyChanges |= readerPool.release(merge.readers.get(i), drop);
} catch (Throwable t) { } catch (Throwable t) {
if (th == null) { if (th == null) {
th = t; th = t;
@ -3362,11 +3363,15 @@ public class IndexWriter implements Closeable {
} }
} }
// If any errors occured, throw it. if (suppressExceptions && anyChanges) {
checkpoint();
}
// If any error occured, throw it.
if (!suppressExceptions && th != null) { if (!suppressExceptions && th != null) {
if (th instanceof IOException) throw (IOException) th;
if (th instanceof RuntimeException) throw (RuntimeException) th; if (th instanceof RuntimeException) throw (RuntimeException) th;
if (th instanceof Error) throw (Error) th; if (th instanceof Error) throw (Error) th;
// defensive code - we should not hit unchecked exceptions
throw new RuntimeException(th); throw new RuntimeException(th);
} }
} }