Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress all exceptions during DeleteOnExitPathHook #1409

Merged
merged 1 commit into from
Aug 19, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package htsjdk.samtools.util.nio;

import htsjdk.samtools.util.Log;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
Expand All @@ -16,6 +18,7 @@
* @author Daniel Gomez-Sanchez (magicDGS)
*/
public class DeleteOnExitPathHook {
private static final Log LOG = Log.getInstance(DeleteOnExitPathHook.class);
private static LinkedHashSet<Path> paths = new LinkedHashSet<>();
static {
Runtime.getRuntime().addShutdownHook(new Thread(DeleteOnExitPathHook::runHooks));
Expand Down Expand Up @@ -55,8 +58,8 @@ static void runHooks() {
for (Path path : toBeDeleted) {
try {
Files.delete(path);
} catch (IOException | SecurityException e) {
// do nothing if cannot be deleted, because it is a shutdown hook
} catch (Exception e) {
LOG.debug(e, "Failed to delete file: ", path, " during shutdown because we encountered an exception.");
}
}
}
Expand Down