diff --git a/lucene/test-framework/src/java/org/apache/lucene/tests/util/fst/FSTTester.java b/lucene/test-framework/src/java/org/apache/lucene/tests/util/fst/FSTTester.java index d80cbf58dc4..07f877575b0 100644 --- a/lucene/test-framework/src/java/org/apache/lucene/tests/util/fst/FSTTester.java +++ b/lucene/test-framework/src/java/org/apache/lucene/tests/util/fst/FSTTester.java @@ -283,14 +283,17 @@ public class FSTTester { } } FST fst = fstCompiler.compile(); - ; if (useOffHeap) { indexOutput.close(); - try (IndexInput in = dir.openInput("fstOffHeap.bin", IOContext.DEFAULT)) { - fst = new FST<>(fst.getMetadata(), in); - } finally { + if (fst == null) { dir.deleteFile("fstOffHeap.bin"); + } else { + try (IndexInput in = dir.openInput("fstOffHeap.bin", IOContext.DEFAULT)) { + fst = new FST<>(fst.getMetadata(), in); + } finally { + dir.deleteFile("fstOffHeap.bin"); + } } } else if (random.nextBoolean() && fst != null) { IOContext context = LuceneTestCase.newIOContext(random);