mirror of https://github.com/apache/lucene.git
use try-w-resources so Directory is closed even on assumption violation
This commit is contained in:
parent
0e9307bb84
commit
7ff31daeb0
|
@ -34,7 +34,7 @@ public abstract class BaseMergePolicyTestCase extends LuceneTestCase {
|
||||||
protected abstract MergePolicy mergePolicy();
|
protected abstract MergePolicy mergePolicy();
|
||||||
|
|
||||||
public void testForceMergeNotNeeded() throws IOException {
|
public void testForceMergeNotNeeded() throws IOException {
|
||||||
Directory dir = newDirectory();
|
try (Directory dir = newDirectory()) {
|
||||||
final AtomicBoolean mayMerge = new AtomicBoolean(true);
|
final AtomicBoolean mayMerge = new AtomicBoolean(true);
|
||||||
final MergeScheduler mergeScheduler = new SerialMergeScheduler() {
|
final MergeScheduler mergeScheduler = new SerialMergeScheduler() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -78,7 +78,7 @@ public abstract class BaseMergePolicyTestCase extends LuceneTestCase {
|
||||||
writer.forceMerge(maxNumSegments);
|
writer.forceMerge(maxNumSegments);
|
||||||
}
|
}
|
||||||
writer.close();
|
writer.close();
|
||||||
dir.close();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue