Fix compiler warnings in tests

This commit is contained in:
Simon Willnauer 2020-04-18 14:42:16 +02:00
parent 113043b1ed
commit 9881dc031c
1 changed files with 40 additions and 38 deletions

View File

@ -4090,8 +4090,9 @@ public class TestIndexWriter extends LuceneTestCase {
}
public void testSegmentCommitInfoId() throws IOException {
try (Directory dir = newDirectory();
IndexWriter writer = new IndexWriter(dir,
try (Directory dir = newDirectory()) {
SegmentInfos segmentCommitInfos;
try (IndexWriter writer = new IndexWriter(dir,
new IndexWriterConfig().setMergePolicy(NoMergePolicy.INSTANCE))) {
Document doc = new Document();
doc.add(new NumericDocValuesField("num", 1));
@ -4102,7 +4103,7 @@ public class TestIndexWriter extends LuceneTestCase {
doc.add(new StringField("id", "2", Field.Store.NO));
writer.addDocument(doc);
writer.commit();
SegmentInfos segmentCommitInfos = SegmentInfos.readLatestCommit(dir);
segmentCommitInfos = SegmentInfos.readLatestCommit(dir);
byte[] id = segmentCommitInfos.info(0).getId();
byte[] segInfoId = segmentCommitInfos.info(0).info.getId();
@ -4129,7 +4130,8 @@ public class TestIndexWriter extends LuceneTestCase {
assertEquals(3, segmentCommitInfos.size());
assertNotEquals(StringHelper.idToString(id), StringHelper.idToString(segmentCommitInfos.info(0).getId()));
assertEquals(StringHelper.idToString(segInfoId), StringHelper.idToString(segmentCommitInfos.info(0).info.getId()));
writer.close();
}
try (Directory dir2 = newDirectory();
IndexWriter writer2 = new IndexWriter(dir2,
new IndexWriterConfig().setMergePolicy(NoMergePolicy.INSTANCE))) {