Fix NPE on off-heap test and FST is null (#12894)

This commit is contained in:
Dzung Bui 2023-12-09 02:59:39 +09:00 committed by GitHub
parent 1c4c1c831d
commit fb269c9e64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 4 deletions

View File

@ -283,14 +283,17 @@ public class FSTTester<T> {
}
}
FST<T> 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);