Delete unpacked jars when the JVM exits

Update `JarFileArchive` so that any unpacked files are now deleted when
the JVM exits.

Closes gh-25773
pull/26093/head
Phillip Webb 4 years ago
parent 05f61bccea
commit ec21202d54

@ -158,6 +158,7 @@ public class JarFileArchive implements Archive {
private void unpack(JarEntry entry, Path path) throws IOException { private void unpack(JarEntry entry, Path path) throws IOException {
createFile(path); createFile(path);
path.toFile().deleteOnExit();
try (InputStream inputStream = this.jarFile.getInputStream(entry); try (InputStream inputStream = this.jarFile.getInputStream(entry);
OutputStream outputStream = Files.newOutputStream(path, StandardOpenOption.WRITE, OutputStream outputStream = Files.newOutputStream(path, StandardOpenOption.WRITE,
StandardOpenOption.TRUNCATE_EXISTING)) { StandardOpenOption.TRUNCATE_EXISTING)) {

Loading…
Cancel
Save