use try-w-resources so Directory is closed even on assumption violation

This commit is contained in:
Mike McCandless 2016-02-15 18:42:24 -05:00
parent 0e9307bb84
commit 7ff31daeb0
1 changed files with 40 additions and 40 deletions

View File

@ -34,7 +34,7 @@ public abstract class BaseMergePolicyTestCase extends LuceneTestCase {
protected abstract MergePolicy mergePolicy();
public void testForceMergeNotNeeded() throws IOException {
Directory dir = newDirectory();
try (Directory dir = newDirectory()) {
final AtomicBoolean mayMerge = new AtomicBoolean(true);
final MergeScheduler mergeScheduler = new SerialMergeScheduler() {
@Override
@ -78,7 +78,7 @@ public abstract class BaseMergePolicyTestCase extends LuceneTestCase {
writer.forceMerge(maxNumSegments);
}
writer.close();
dir.close();
}
}
}