mirror of https://github.com/apache/lucene.git
Prevent warning on empty try-with-resources
This commit is contained in:
parent
5c024e6afc
commit
3d34728c4b
|
@ -1213,6 +1213,7 @@ public abstract class BaseDirectoryTestCase extends LuceneTestCase {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try (IndexOutput out = dir.createOutput(candidate, IOContext.DEFAULT)) {
|
try (IndexOutput out = dir.createOutput(candidate, IOContext.DEFAULT)) {
|
||||||
|
out.getFilePointer(); // just fake access to prevent compiler warning
|
||||||
}
|
}
|
||||||
fsDir.deleteFile(candidate);
|
fsDir.deleteFile(candidate);
|
||||||
if (fsDir.checkPendingDeletions()) {
|
if (fsDir.checkPendingDeletions()) {
|
||||||
|
@ -1246,12 +1247,14 @@ public abstract class BaseDirectoryTestCase extends LuceneTestCase {
|
||||||
|
|
||||||
if (random().nextBoolean()) {
|
if (random().nextBoolean()) {
|
||||||
try (IndexOutput out = fsDir.createOutput(fileName + "z", IOContext.DEFAULT)) {
|
try (IndexOutput out = fsDir.createOutput(fileName + "z", IOContext.DEFAULT)) {
|
||||||
|
out.getFilePointer(); // just fake access to prevent compiler warning
|
||||||
}
|
}
|
||||||
// Make sure we can rename onto the deleted file:
|
// Make sure we can rename onto the deleted file:
|
||||||
fsDir.renameFile(fileName + "z", fileName);
|
fsDir.renameFile(fileName + "z", fileName);
|
||||||
} else {
|
} else {
|
||||||
// write the file again
|
// write the file again
|
||||||
try (IndexOutput out = dir.createOutput(fileName, IOContext.DEFAULT)) {
|
try (IndexOutput out = dir.createOutput(fileName, IOContext.DEFAULT)) {
|
||||||
|
out.getFilePointer(); // just fake access to prevent compiler warning
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assertEquals(0, fsDir.fileLength(fileName));
|
assertEquals(0, fsDir.fileLength(fileName));
|
||||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.lucene.store;
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.FileSystem;
|
|
||||||
import java.nio.file.NoSuchFileException;
|
import java.nio.file.NoSuchFileException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -46,8 +45,6 @@ import org.apache.lucene.index.IndexWriter;
|
||||||
import org.apache.lucene.index.IndexWriterConfig;
|
import org.apache.lucene.index.IndexWriterConfig;
|
||||||
import org.apache.lucene.index.NoDeletionPolicy;
|
import org.apache.lucene.index.NoDeletionPolicy;
|
||||||
import org.apache.lucene.index.SegmentInfos;
|
import org.apache.lucene.index.SegmentInfos;
|
||||||
import org.apache.lucene.mockfile.FilterFileSystem;
|
|
||||||
import org.apache.lucene.mockfile.VirusCheckingFS;
|
|
||||||
import org.apache.lucene.util.IOUtils;
|
import org.apache.lucene.util.IOUtils;
|
||||||
import org.apache.lucene.util.LuceneTestCase;
|
import org.apache.lucene.util.LuceneTestCase;
|
||||||
import org.apache.lucene.util.TestUtil;
|
import org.apache.lucene.util.TestUtil;
|
||||||
|
@ -423,6 +420,7 @@ public class MockDirectoryWrapper extends BaseDirectoryWrapper {
|
||||||
deleteFile(name);
|
deleteFile(name);
|
||||||
|
|
||||||
try (IndexOutput out = in.createOutput(name, LuceneTestCase.newIOContext(randomState))) {
|
try (IndexOutput out = in.createOutput(name, LuceneTestCase.newIOContext(randomState))) {
|
||||||
|
out.getFilePointer(); // just fake access to prevent compiler warning
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue