Don't swallow exceptions in Store#close(). (#39035) (#39622)

Store#close() swallows any `IOException`.

Relates #39030
This commit is contained in:
Adrien Grand 2019-03-04 10:58:43 +01:00 committed by GitHub
parent 934946a232
commit 782f873165
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -87,6 +87,7 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.io.UncheckedIOException;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.util.ArrayList;
@ -416,16 +417,15 @@ public class Store extends AbstractIndexShardComponent implements Closeable, Ref
}
private void closeInternal() {
try {
// Leverage try-with-resources to close the shard lock for us
try (Closeable c = shardLock) {
try {
directory.innerClose(); // this closes the distributorDirectory as well
} finally {
onClose.accept(shardLock);
}
} catch (IOException e) {
logger.debug("failed to close directory", e);
} finally {
IOUtils.closeWhileHandlingException(shardLock);
throw new UncheckedIOException(e);
}
}