diff --git a/lucene/core/src/java/org/apache/lucene/index/IndexFileDeleter.java b/lucene/core/src/java/org/apache/lucene/index/IndexFileDeleter.java index 9ff0005dc65..c2f02eb53b1 100644 --- a/lucene/core/src/java/org/apache/lucene/index/IndexFileDeleter.java +++ b/lucene/core/src/java/org/apache/lucene/index/IndexFileDeleter.java @@ -92,7 +92,7 @@ final class IndexFileDeleter implements Closeable { /* Holds files we had incref'd from the previous * non-commit checkpoint: */ - private List> lastFiles = new ArrayList>(); + private final List lastFiles = new ArrayList(); /* Commits that the IndexDeletionPolicy have decided to delete: */ private List commitsToDelete = new ArrayList(); @@ -361,14 +361,13 @@ final class IndexFileDeleter implements Closeable { refresh(null); } + @Override public void close() throws IOException { // DecRef old files from the last checkpoint, if any: assert locked(); - int size = lastFiles.size(); - if (size > 0) { - for(int i=0;i lastFile : lastFiles) { - decRef(lastFile); - } + decRef(lastFiles); lastFiles.clear(); // Save files so we can decr on next checkpoint/commit: - lastFiles.add(segmentInfos.files(directory, false)); + lastFiles.addAll(segmentInfos.files(directory, false)); } if (infoStream.isEnabled("IFD")) { long t1 = System.nanoTime();